Skip to content

Sidebar

⋯

Import Sidebar from @nesra/ui/sidebar or the package root. Put MenuButton inside Menu for ordinary destinations. MenuButton supplies its own list item, including when rendered through a fragment or another component. The same navigation items render in a desktop panel or a modal mobile drawer.

The account menu shows the selected account and accepts application actions through Sidebar.AccountMenu.Item.

Sidebar.AccountCard is Figma’s Nav account card with Type=Simple. It shows the signed-in account above a top border and a sign-out button, and it opens no menu. The application owns sign-out through onSignOut.

Use Base UI Collapsible for a section with child destinations. Group labels and the footer remain separate from the scrollable content.

Menu items can include a count, a trailing action, or a group-level action. Trailing actions can remain hidden until the item receives hover or keyboard focus.

Sidebar.MenuButton, Sidebar.MenuSubButton, and Sidebar.MenuSkeleton default to size="compact", Figma’s nav item. Each row is 30px: a 28px item with 1px above and below. The label uses Body/XSmall at 12/16px: Regular at rest, and Semibold while hovered, focused, or current. The leading icon is 16px, the icon-to-label gap is 6px, and a Sidebar.MenuBadge beside a compact item is 16px tall with 0/6px padding.

The header uses Sidebar.Logo, the 32px logo tile, and Sidebar.Trigger, Figma’s 28px Logo sidebar navigation button. Hover the trigger for its Open sidebar or Close sidebar tooltip. The footer ends with Sidebar.AccountCard. In the collapsed rail, the header stacks the logo above the trigger, and the account card stacks the avatar above its sign-out button.

To keep the 36px row from 0.x, set size="default" on Sidebar.MenuButton and Sidebar.MenuSkeleton, and size="md" on Sidebar.MenuSubButton. Use one density per menu.

Place Sidebar.Input in the header and use Sidebar.MenuSkeleton while destinations are loading.

Below 640px, the persistent 56px header opens a 311px modal drawer. The drawer uses the same navigation composition and closes through Escape, the backdrop, or its close button.

Sidebar.Provider
├─ Sidebar
│ ├─ Sidebar.Header
│ │ ├─ Sidebar.Logo
│ │ ├─ Sidebar.Trigger
│ │ └─ Sidebar.Input
│ ├─ Sidebar.Separator
│ ├─ Sidebar.Content
│ │ └─ Sidebar.Group
│ │ ├─ Sidebar.GroupLabel
│ │ ├─ Sidebar.GroupAction
│ │ └─ Sidebar.GroupContent
│ │ └─ Sidebar.Menu
│ │ ├─ Sidebar.MenuButton
│ │ └─ Sidebar.MenuItem (for actions or nested content)
│ │ ├─ Sidebar.MenuButton
│ │ ├─ Sidebar.MenuAction
│ │ ├─ Sidebar.MenuBadge
│ │ ├─ Sidebar.MenuSkeleton
│ │ └─ Sidebar.MenuSub
│ │ ├─ Sidebar.MenuSubButton
│ │ └─ Sidebar.MenuSubItem (optional wrapper)
│ │ └─ Sidebar.MenuSubButton
│ └─ Sidebar.Footer
│ └─ Sidebar.AccountMenu or Sidebar.AccountCard
└─ Sidebar.Inset

Sidebar.MenuButton is built on Nesra Button; render it as a link with render={<a href="…" />}. Sidebar.Collapsible.Root, Trigger, and Panel wrap nested routes. Put Sidebar.MenuSub inside its panel.

Sidebar.AccountMenu fits in Sidebar.Footer. Compose its trigger, popup, account choices, and application actions as shown in the account menu example. Use DropdownMenu.Item for actions that belong to the application. Use Sidebar.AccountCard instead when the footer only shows the account and a sign-out button.

Figma Code
Logo sidebar navigation, State=Default Sidebar.Trigger on desktop
Logo sidebar navigation, State=Hover Sidebar.Trigger while hovered, with its tooltip
Logo sidebar navigation, Icon=panel-left-close Sidebar.Trigger while expanded
Logo sidebar navigation, Icon=panel-right-close Sidebar.Trigger while collapsed
Sidebar navigation, Show Tooltip Sidebar.Trigger tooltip. Pass false to omit it
Sidebar navigation header logo-wrapper Sidebar.Logo
Nav account card, Type=Card Sidebar.AccountMenu
Nav account card, Type=Simple Sidebar.AccountCard
Nav account card, Breakpoint=Mobile The same parts inside the mobile drawer
.Nav account card menu item, Type=Menu item Sidebar.AccountMenu.Item
.Nav account card menu item, Type=Account Sidebar.AccountMenu.AccountItem

Figma names the 28px toggle “Logo sidebar navigation”, but it holds a panel icon, not the logo. The logo is the separate 32px logo-wrapper frame beside it, which Sidebar.Logo renders.

Figma does not define these states. The code does the following:

  • Sidebar.Logo has no hover state. Rendered as a link, it shows the focus ring on keyboard focus.
  • Type=Simple has no collapsed-rail variant. The card hides the name and email, then stacks the avatar above the sign-out button.
  • The sign-out button has no Figma hover state. It uses foundation-bg-brand-primary-50, like the account card trigger’s chevron button.
  • The sign-out button has no visible label in Figma. Its accessible name is “Sign out”.

Sidebar colors come from semantic roles, so the panel follows .dark or data-theme="dark" on an ancestor.

Part Roles
Panel and mobile header foundation-bg-neutral, stroke-border
Group label text-support
Menu button and sub-button text-support on alpha-transparent. Hover: action-secondary-hover, text-body. Current page: foundation-bg-brand-primary-50, text-body
Menu badge foundation-bg-brand-primary-50, stroke-border, text-secondary
Compact menu icon icon-muted. Hover, focus, and current page: icon-neutral
Keyboard focus shadow-nesra-focus-ring: a 3px effects-focus-ring ring on menu buttons, actions, the trigger, and the account card
Trigger foundation-bg-neutral, stroke-border-strong, shadow-nesra-xs-skeuomorphic; icon icon-muted, hover icon-neutral; tooltip foundation-bg-inverse
Logo icon-static-dark tile
Account card (Simple) stroke-border top border; name text-body, email text-tertiary; sign-out icon icon-neutral, hover foundation-bg-brand-primary-50
Account card trigger foundation-bg-neutral, stroke-border; name text-body, email text-tertiary
Account menu foundation-bg-brand-primary-50 frame with a foundation-bg-neutral panel, stroke-border dividers and shadow-lg
Account menu items text-support; highlighted action-secondary-hover, text-body; shortcut stroke-border, text-tertiary
Account choices Selected foundation-bg-brand-primary-50 with an action-primary-default radio; unselected radio stroke-brand-primary

Sidebar.Logo uses the icon-static-dark tile, which stays gray-950 in both modes so a light logo remains visible.

Give Sidebar a label identifying its navigation region. Sidebar.MenuButton renders a button by default and sets aria-current="page" when active is true; use its render prop for a route link. Sidebar.Trigger controls desktop expansion or opens a focus-trapped mobile dialog below 640px. The drawer closes with Escape, the backdrop, or its close button. Name every icon-only action and keep a text label inside collapsed menu buttons.

Every part accepts the native props for its rendered element plus className, unless noted otherwise.

Prop Type Default Description
open boolean — Controlled desktop expanded state.
defaultOpen boolean true Initial uncontrolled desktop state.
onOpenChange (open: boolean) => void — Called after a desktop disclosure request.
mobileBreakpoint number 640 Width below which the sidebar becomes a drawer.

The provider persists desktop state in the sidebar_state cookie for seven days. Command+B on macOS and Control+B elsewhere toggle the active provider. The context accepts both boolean values and updater functions through setOpen and setOpenMobile.

Prop Type Default Description
label string required Accessible name for the navigation region.

The desktop sidebar has one disclosure behavior: it switches between the 248px expanded panel and the 72px icon rail. The mobile drawer composes Nesra Sheet and is at most 311px.

Built on Button. It toggles desktop expansion or the mobile drawer. The same action is available with Command+B or Control+B.

On desktop it is Figma’s 28px Logo sidebar navigation button: a 6px-radius stroke-border-strong frame with a 16px icon. The icon is PanelLeftClose while expanded and PanelRightClose while collapsed. Hover turns the icon from icon-muted to icon-neutral and shows a tooltip on the right. Its accessible name is “Toggle sidebar” and aria-expanded reports the state. In mobile mode it is a 32px ghost button that opens the drawer, with the name “Open navigation” and no tooltip.

Prop Type Default Description
tooltip ReactNode | false "Close sidebar" or "Open sidebar" Desktop tooltip. false omits it.
children ReactNode Panel icon for the current state Replaces the icon.

Renders the 32px logo tile from the sidebar header: an 8px-radius icon-static-dark frame that clips its content. A child img or svg fills the tile. The tile stays visible in the collapsed rail.

Prop Type Default Description
render ReactElement — Replaces the div, for example <a href="/" aria-label="Home" />.

Give a decorative logo alt="". When the logo is the page’s only product name, give it a text alternative, or name the link that renders it.

Renders the flexible <main> region beside the desktop sidebar.

Nesra Input sized for search or filtering inside the sidebar header.

Horizontal divider between sidebar regions. It renders role="separator".

Renders a 56px <header> only while the provider is in mobile mode. Place a Sidebar.Trigger here so the closed drawer remains reachable.

Fixed region above the scrollable content. Use it for the product or workspace identity.

Scrollable region between Sidebar.Header and Sidebar.Footer.

Fixed bottom region for account controls or persistent actions.

Import Sidebar and the SidebarAccount type from @nesra/ui/sidebar. Place the parts in this order:

Sidebar.AccountMenu.Root
├─ Sidebar.AccountMenu.Trigger
└─ Sidebar.AccountMenu.Content
├─ Sidebar.AccountMenu.Panel
│ ├─ Sidebar.AccountMenu.ActionGroup
│ │ └─ Sidebar.AccountMenu.Item
│ ├─ Sidebar.AccountMenu.AccountGroup
│ │ └─ Sidebar.AccountMenu.AccountItem
│ └─ Sidebar.AccountMenu.AddAccount
└─ Sidebar.AccountMenu.Footer
└─ Sidebar.AccountMenu.Item

The application owns the displayed account, selected account, account changes, and application actions. Sidebar.AccountMenu is an alias for Sidebar.AccountMenu.Root.

Field Type Required Effect
id string Yes Identifies an account; keep IDs unique among choices.
name string Yes Displays the account name and supplies avatar initials.
email string Yes Displays the secondary account text.
src string No Supplies an avatar image URL.

Owns the menu’s open state and forwards DropdownMenu root props. It starts closed when uncontrolled.

Prop Type Default Effect
open boolean — Controls whether the menu is open.
defaultOpen boolean false Sets the initial uncontrolled state.
onOpenChange (open: boolean, details) => void — Runs when the open state changes.

Displays the supplied account in the sidebar footer. In the collapsed icon rail, only its avatar remains visible. Its accessible name begins with “Open account menu for” and ends with the account name.

Prop Type Default Effect
account SidebarAccount required Supplies the displayed account.

Accepts DropdownMenu.Trigger props such as disabled and className and forwards its ref to the button. children and render are unavailable because the trigger renders its own account layout.

Renders the menu in a portal. className styles the popup, container selects the portal host, and the ref points to the popup. Other DropdownMenu.Content positioner props are forwarded.

Prop Type Default Effect
side "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end" "right" Places the popup; use "bottom" in the mobile drawer.
align "start" | "center" | "end" "end" Aligns the popup along its side.
sideOffset number 8 Sets the distance from the trigger in pixels.

Native div containing the white action and account sections above the tinted footer. Accepts native div props and className; its ref points to the div.

Groups application actions inside Panel. Accepts DropdownMenu.Group props and className and forwards its ref to the group. Render Sidebar.AccountMenu.Item children for actions such as settings or invitations; their handlers belong to the application.

Renders an action row inside ActionGroup or Footer. It inherits DropdownMenu.Item props such as onClick, disabled, and render; its ref points to the rendered item.

Prop Type Default Effect
children ReactNode — Renders the action label.
icon ReactNode — Renders a leading icon.
shortcut ReactNode — Displays a trailing shortcut without registering its keys.

Groups account choices inside Panel and renders a visible heading above them. Accepts other DropdownMenu.Group props and className and forwards its ref to the group.

Prop Type Default Effect
label ReactNode required Renders the account group heading.

Displays an account choice. It inherits DropdownMenu.Item props such as disabled, closeOnClick, and variant; children, render, and onClick are unavailable because the item renders its own account layout and selection callback. Its ref points to the rendered item.

Prop Type Default Effect
account SidebarAccount required Supplies the choice’s avatar, name, and email.
selected boolean false Applies selected styling and sets aria-current="true".
onAccountSelect (account: SidebarAccount) => void — Runs when the item is chosen, receiving that item’s account.

Selection does not update the trigger or selected props automatically. Update application state in onAccountSelect, then pass the current account to Trigger and mark its matching AccountItem as selected.

Renders the outlined add-account action inside Panel. It inherits DropdownMenu.Item props, including onClick, disabled, and closeOnClick. render is unavailable because the part supplies its own button. Its ref points to the rendered item.

Prop Type Default Effect
children ReactNode "Add account" Replaces the visible button label.

Supply an onClick handler to open the application’s add-account flow. Omit this part when adding accounts is unavailable.

Tinted action group below Panel. Accepts DropdownMenu.Group props and className and forwards its ref to the group. Render Sidebar.AccountMenu.Item children for application actions such as sign out.

Renders Figma’s Nav account card with Type=Simple: a 40px avatar, the name and email, and a 28px sign-out button, above a stroke-border top border. It has 20px top padding and 8px side padding. Inside the mobile drawer it has 16px top padding and no side padding. In the collapsed rail it hides the name and email visually and stacks the avatar above the sign-out button. Accepts native div props and className; its ref points to the div.

Prop Type Default Description
account SidebarAccount required Supplies the displayed avatar, name, and email.
onSignOut () => void — Runs when the sign-out button is pressed. Unset omits the button.
signOutLabel string "Sign out" Accessible name of the sign-out button.

Relative container for one related navigation section.

Section label that becomes visually hidden when the desktop sidebar is collapsed.

Optional icon action aligned with the group label. Built on Button; hidden while collapsed.

Structural wrapper around a group’s Sidebar.Menu.

Unordered list for top-level navigation items.

Relative list item containing a primary row and optional action, badge, or nested menu. Sidebar.MenuButton adds it automatically. Write it explicitly when the row has siblings or a collapsible section.

Prop Type Default Description
active boolean false Applies current-route styling and aria-current="page".
isActive boolean — shadcn-compatible alias for active.
icon ReactNode — Leading icon that remains visible in the collapsed rail.
variant "default" | "outline" "default" Row treatment.
size "default" | "sm" | "lg" | "compact" "compact" Row density. "compact" is the 28px Figma nav item.
tooltip ReactNode — Tooltip shown beside the collapsed icon rail.
render ReactElement — Replaces the default button, for example <a href="/home" />.

It uses Nesra Button with ghost styling. Text is never underlined, including when the rendered element is an anchor.

Secondary icon action positioned at the end of a menu item. Built on Button and hidden in the collapsed rail. Set showOnHover to reveal it while its item is hovered or keyboard-focused.

Compact text or count positioned at the end of a menu item and hidden while collapsed. Beside a compact Sidebar.MenuButton, it is 16px tall with 6px horizontal padding.

Loading row with an optional showIcon placeholder and a stable randomized text width. It defaults to size="compact", a 28px row with a 16px icon placeholder. Set size="default" beside 36px rows.

Indented child-route list. Place it inside Sidebar.Collapsible.Panel.

List item for one child route. Sidebar.MenuSubButton adds it automatically. Write it explicitly when the row needs additional content.

Smaller child-route row built on Button. It accepts active, the isActive alias, size="sm" | "md" | "compact", and render with the same meanings as Sidebar.MenuButton. It defaults to "compact", which adds 1px above and below so each child row is 30px. Use "md" under a size="default" Sidebar.MenuButton.

Figma-aligned 16px chevron. It swaps between ChevronDown and ChevronUp from the data-panel-open state of Sidebar.Collapsible.Trigger, and is omitted from the collapsed icon rail.

Sidebar.Collapsible.Root, .Trigger, and .Panel expose the corresponding Base UI Collapsible props. Render Sidebar.MenuButton through .Trigger to create a full-width disclosure row.

Returns shadcn-compatible state, open, setOpen, isMobile, openMobile, setOpenMobile, and toggleSidebar values inside Sidebar.Provider. Routing remains the consuming application’s responsibility.