@edux-design/chrome

中文文档
0.6.0发布于 2026/11/03TypeScriptESM + CJS近 30 天下载 2086

Responsive sidebar primitives (Sidebar, SidebarHeader, SidebarSection, SidebarItem, SidebarFooter) used to build the application chrome in Edux products. The components manage expand/collapse state, tooltips for the collapsed view, and consisten

原始使用文档
文档目录10 节
  1. Installation
  2. Token contract
  3. Usage
  4. Features
  5. Development
  6. Notes
  7. Docked panels
  8. Additional components
  9. Scroll-edge affordances
  10. Controlled and embedded Sidebar

@edux-design/chrome

Responsive sidebar primitives (Sidebar, SidebarHeader, SidebarSection, SidebarItem, SidebarFooter) used to build the application chrome in Edux products. The components manage expand/collapse state, tooltips for the collapsed view, and consistent spacing/focus styles.


Installation

pnpm add @edux-design/chrome @edux-design/utils @edux-design/tooltips @edux-design/icons
# or
npm install @edux-design/chrome @edux-design/utils @edux-design/tooltips @edux-design/icons

Peer deps: react@^19.1.0, react-dom@^19.1.0.

Token contract

Sidebar navigation and profile rows use the declared gap-12 spacing token; the header and footer use declared py-12; and the collapsed rail uses the declared w-72 token. The expanded rail width (240px), header height (60px), and logo wrapper width (40px) remain explicit component geometry because the current theme has no matching declared dimensions. The footer shadow pseudo-element keeps its empty content and 2px translate as local implementation details.

No new semantic tokens are introduced. Consumers should import @edux-design/tokens/theme so the shared utilities resolve consistently.


Usage

import {
  Sidebar,
  SidebarHeader,
  SidebarSection,
  SidebarItem,
  SidebarFooter,
} from "@edux-design/chrome";
import { Users, Settings } from "@edux-design/icons";

export function AppChrome() {
  return (
    <Sidebar defaultExpanded>
      <SidebarHeader logo={<span className="text-lg font-bold">Edux</span>} />

      <SidebarSection title="Workspace">
        <SidebarItem icon={<Users />} label="People" active />
        <SidebarItem icon={<Settings />} label="Settings" />
      </SidebarSection>

      <SidebarFooter>
        <button className="text-sm">Logout</button>
      </SidebarFooter>
    </Sidebar>
  );
}

Features

  • Internal context tracks isExpanded and exposes a toggle button in SidebarHeader.
  • When collapsed, items show tooltips (via @edux-design/tooltips) so labels remain discoverable.
  • Sections automatically hide their titles when collapsed to keep the column skinny.
  • Footer content sticks to the bottom for account/profile controls.

Development

pnpm --filter @edux-design/chrome lint
pnpm --filter @edux-design/chrome check-types
pnpm --filter @edux-design/chrome build

Stories live at src/demos/Sidebar.stories.jsx and cover both expanded/collapsed states.


Notes

  • SidebarItem renders a focusable list item (TooltipTrigger). Pass onClick or wrap it with routing logic (e.g., next/link via asChild support if needed).
  • The TODOs inside Sidebar.jsx (avatar presets, padding fixes) are good starter issues if you need enhancements.
  • Because the layout relies on Tailwind tokens, keep overrides minimal to avoid drift between apps.

Docked panels

For non-modal inspector, search and editing docks, use the eight DockedPanel* primitives. They are separate from the navigation Sidebar* API. See the API and integration guide for imports, class/ref targets, scroll ownership, theming and the Payload-local export mapping. Storybook demos live under Chrome / DockedPanel.

Additional components

Semantic sidebar footer profiles.

Feature-page chrome.

Resizable panes and handles.

Scroll-edge affordances

useScrollShadows, observeScrollShadows and HORIZONTAL_SCROLL_SHADOW_SIDES observe an existing viewport without creating viewport wrappers. They support mutable ref replacement, four physical edges, thresholds, content/viewport resize, RTL and cleanup. The optional inset shadow uses the existing --color-border-subtle semantic colour; host overlays remain decorative and must pass pointers through. See the API, host migration inventory and verification guide.

Controlled and embedded Sidebar

Sidebar preserves its existing expanded app defaults (240px expanded, existing w-72 collapsed class and viewport height). Use expanded with onExpandedChange(next: boolean) for host-controlled expansion, or defaultExpanded for an initial uncontrolled value. Each enabled, uncancelled toggle activation requests one change. Controlled updates and changes to default props do not emit callbacks. The host may reject a controlled request.

The root forwards native aside attributes/styles/events and an HTMLElement ref. Its default accessible name is still “Sidebar navigation”; supply your own aria-label/aria-labelledby. Public data-sidebar, data-expanded, data-layout and data-scroll-mode markers describe component state.

Use layout="embedded" to fill a bounded host without fixed app width, viewport height, border or shadow. Embedded mode renders a named native nav; app mode keeps the existing aside/complementary semantics. Native role and accessible naming props may override these defaults to fit the host landmark. scrollMode="internal" (default) gives the supported data-sidebar-scroll region min-height-safe flex scrolling. scrollProps and scrollRef expose that actual div's attributes, class/style, events and ref. scrollMode="external" leaves overflow visible and lets an ancestor own scrolling. The root/scroll region are stable across expansion and scroll-mode changes. Changing layout switches the semantic root element and updates root/scroll refs; choose a stable layout for long-lived interactive content. Chrome's existing overflow observer supplies internal edge shadows; external scroll mode attaches no internal overflow observer.

SidebarHeader accepts translated expandLabel/collapseLabel, native header props/ref, and toggleProps/toggleRef for its button. Toggle type, expanded state and control association remain component-owned. toggleProps.onClick or root capture handlers can cancel the expansion request with preventDefault. Collapsed items retain their accessible names. Collapse preserves button focus; if it removes a focused logo/control, focus recovers to the toggle (or root). onCollapseAutoFocus(event) may prevent that recovery to choose a host fallback. Outside focus is preserved. The root's default tabIndex=-1 adds no tab stop. Native hidden and inert root props support a host that keeps navigation mounted while closed. hidden suppresses the root's flex display; the host still owns moving focus to a visible control before hiding the navigation.

<Sidebar
  expanded={expanded}
  onExpandedChange={setExpanded}
  layout="embedded"
  aria-label="Book navigation"
  ref={sidebarRef}
  scrollRef={scrollRef}
  scrollProps={{ role: 'region', 'aria-label': 'Book sections', tabIndex: 0 }}
>
  <SidebarHeader expandLabel="Expand navigation" collapseLabel="Collapse navigation" />
  <SidebarSection title="Sections">{/* existing SidebarItems */}</SidebarSection>
</Sidebar>

Routes, permissions, breakpoints, outer mobile visibility and focus return after host closure remain host policy. The mobile demo uses expansion requests and public refs to close/reopen its outer host, without English selectors, width inspection or synthetic clicks. Storybook's Sidebar contracts cover controlled, embedded internal/external scroll, mobile, translated labels and light/dark modes.

版本与发布记录

@edux-design/chrome 共发布 19 个版本,首次发布于 2025/09/27;过去 12 个月发布了 15 个版本。

版本发布日期距今
0.6.0latest2026/11/0311 天前
0.5.12026/11/0113 天前
0.5.02026/11/0113 天前
0.4.12026/10/3114 天前
0.4.02026/10/2916 天前
0.3.12026/10/2816 天前

关于 @edux-design/chrome 的常见问题

@edux-design/chrome 是什么?

Responsive sidebar primitives (Sidebar, SidebarHeader, SidebarSection, SidebarItem, SidebarFooter) used to build the application chrome in Edux products. The components manage expand/collapse state, tooltips for the collapsed view, and consisten

如何安装 @edux-design/chrome?

在项目目录运行 npm install @edux-design/chrome,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.1.0)、react-dom(^19.1.0)、@edux-design/tokens(^0.2.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@edux-design/chrome 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@edux-design/chrome 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@edux-design/chrome 可以商用吗?

@edux-design/chrome 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@edux-design/chrome 的下载量有多少?

根据 npm 官方下载统计,@edux-design/chrome 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,086 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@edux-design/chrome 还在维护吗?

最新版本 0.6.0 发布于 2026/11/03(11 天前);至今共发布 19 个版本,其中过去 12 个月发布了 15 个;首次发布于 2025/09/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。