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.
import { Sidebar } from "@nesra/ui/sidebar";import { House, Settings } from "lucide-react";
export function SidebarMinimalExample() { return ( <Sidebar.Provider mobileBreakpoint={0} className="h-72 overflow-hidden rounded-nesra-md border border-nesra-stroke-border" > <Sidebar label="Main navigation"> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Workspace</Sidebar.GroupLabel> <Sidebar.Menu> <Sidebar.MenuButton render={<a href="#home" aria-label="Home" />} icon={<House />} active > Home </Sidebar.MenuButton> <Sidebar.MenuButton render={<a href="#settings" aria-label="Settings" />} icon={<Settings />} > Settings </Sidebar.MenuButton> </Sidebar.Menu> </Sidebar.Group> </Sidebar.Content> </Sidebar> <Sidebar.Inset className="bg-nesra-foundation-bg-neutral" /> </Sidebar.Provider> );}Examples
Section titled “Examples”Workspace navigation
Section titled “Workspace navigation”import { Sidebar } from "@nesra/ui/sidebar";import { BarChart3, BriefcaseBusiness, FileChartColumn, Folder, House, Inbox, Layers3, Target, Zap,} from "lucide-react";import { ExampleAccountMenu } from "./account-menu";
function WorkspaceHeader() { return ( <Sidebar.Header className="flex items-center gap-nesra-spacing-md group-data-[collapsed=true]/sidebar:flex-col group-data-[collapsed=true]/sidebar:gap-nesra-spacing-lg"> <Sidebar.Logo> <img alt="" src="/logo.png" /> </Sidebar.Logo> <span className="min-w-0 flex-1 group-data-[collapsed=true]/sidebar:hidden"> <span className="block truncate type-nesra-body-small-semibold">Platform Name</span> <span className="block truncate type-nesra-body-xsmall-regular text-nesra-text-support"> By Nesra AI </span> </span> <Sidebar.Trigger /> </Sidebar.Header> );}
function ExpandableItem({ icon, label }: { icon: React.ReactNode; label: string }) { return ( <Sidebar.MenuItem> <Sidebar.Collapsible.Root> <Sidebar.Collapsible.Trigger render={<Sidebar.MenuButton icon={icon} tooltip={label} />}> {label} <Sidebar.MenuChevron /> </Sidebar.Collapsible.Trigger> </Sidebar.Collapsible.Root> </Sidebar.MenuItem> );}
export function SidebarBasicExample() { return ( <Sidebar.Provider mobileBreakpoint={0} className="h-[640px] overflow-hidden rounded-nesra-md border border-nesra-stroke-border" > <Sidebar label="Main navigation" className="group/sidebar"> <WorkspaceHeader /> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Menu</Sidebar.GroupLabel> <Sidebar.GroupContent> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton render={<a href="#home" aria-label="Home" />} active icon={<House />} tooltip="Home" > Home </Sidebar.MenuButton> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.Collapsible.Root defaultOpen> <Sidebar.Collapsible.Trigger render={<Sidebar.MenuButton icon={<BarChart3 />} tooltip="Analytics" />} > Analytics <Sidebar.MenuChevron /> </Sidebar.Collapsible.Trigger> <Sidebar.Collapsible.Panel> <Sidebar.MenuSub> {["Overview", "Revenue", "Traffic", "Reports"].map((label) => ( <Sidebar.MenuSubItem key={label}> <Sidebar.MenuSubButton render={<a href={`#${label.toLowerCase()}`} aria-label={label} />} > {label} </Sidebar.MenuSubButton> </Sidebar.MenuSubItem> ))} </Sidebar.MenuSub> </Sidebar.Collapsible.Panel> </Sidebar.Collapsible.Root> </Sidebar.MenuItem> <ExpandableItem icon={<Folder />} label="Projects" /> <ExpandableItem icon={<Inbox />} label="Inbox" /> <ExpandableItem icon={<FileChartColumn />} label="Report" /> </Sidebar.Menu> </Sidebar.GroupContent> </Sidebar.Group> <Sidebar.Group> <Sidebar.GroupLabel>Your teams</Sidebar.GroupLabel> <Sidebar.GroupContent> <Sidebar.Menu> <ExpandableItem icon={<Target />} label="Marketing" /> <ExpandableItem icon={<Zap />} label="Engineering" /> <ExpandableItem icon={<Layers3 />} label="Design" /> <ExpandableItem icon={<BriefcaseBusiness />} label="Sales" /> </Sidebar.Menu> </Sidebar.GroupContent> </Sidebar.Group> </Sidebar.Content> <Sidebar.Footer className="mt-auto"> <ExampleAccountMenu /> </Sidebar.Footer> </Sidebar> <Sidebar.Inset className="bg-nesra-foundation-bg-neutral" /> </Sidebar.Provider> );}Account menu
Section titled “Account menu”The account menu shows the selected account and accepts application actions through Sidebar.AccountMenu.Item.
import { Sidebar, type SidebarAccount } from "@nesra/ui/sidebar";import { BookOpen, LogOut, Settings, UserRoundPlus } from "lucide-react";import { useState } from "react";
const accounts: SidebarAccount[] = [ { id: "irfan", name: "Irfan Yulianto", email: "irfan@nesra.ai", src: "/avatar/portrait.png" }, { id: "hendra", name: "Hendra Febiawan", email: "hendra@nesra.ai", src: "/avatar/member-1.png" },];
export function ExampleAccountMenu({ side = "right" }: { side?: "bottom" | "right" }) { const [account, setAccount] = useState(accounts[0]);
return ( <Sidebar.AccountMenu.Root> <Sidebar.AccountMenu.Trigger account={account} /> <Sidebar.AccountMenu.Content side={side}> <Sidebar.AccountMenu.Panel> <Sidebar.AccountMenu.ActionGroup> <Sidebar.AccountMenu.Item icon={<Settings aria-hidden="true" />} shortcut="⌘S"> Account settings </Sidebar.AccountMenu.Item> <Sidebar.AccountMenu.Item icon={<UserRoundPlus aria-hidden="true" />}> Invite Member </Sidebar.AccountMenu.Item> <Sidebar.AccountMenu.Item icon={<BookOpen aria-hidden="true" />}> Documentation </Sidebar.AccountMenu.Item> </Sidebar.AccountMenu.ActionGroup> <Sidebar.AccountMenu.AccountGroup label="Switch account"> {accounts.map((option) => ( <Sidebar.AccountMenu.AccountItem account={option} key={option.id} onAccountSelect={setAccount} selected={option.id === account.id} /> ))} </Sidebar.AccountMenu.AccountGroup> <Sidebar.AccountMenu.AddAccount onClick={() => {}} /> </Sidebar.AccountMenu.Panel> <Sidebar.AccountMenu.Footer> <Sidebar.AccountMenu.Item icon={<LogOut aria-hidden="true" />} shortcut="⌥⇧Q"> Sign out </Sidebar.AccountMenu.Item> </Sidebar.AccountMenu.Footer> </Sidebar.AccountMenu.Content> </Sidebar.AccountMenu.Root> );}Account card
Section titled “Account card”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.
import { Sidebar, type SidebarAccount } from "@nesra/ui/sidebar";
const account: SidebarAccount = { id: "irfan", name: "Irfan Yulianto", email: "irfan@nesra.ai", src: "/avatar/portrait.png",};
export function SidebarAccountCardExample() { return ( <div className="w-62"> <Sidebar.AccountCard account={account} onSignOut={() => {}} /> </div> );}Nested navigation
Section titled “Nested navigation”Use Base UI Collapsible for a section with child destinations. Group labels and the footer remain separate from the scrollable content.
import { Sidebar } from "@nesra/ui/sidebar";import { BookOpen, ChartNoAxesCombined, House, Settings } from "lucide-react";
function WorkspaceHeader() { return ( <Sidebar.Header className="flex items-center gap-nesra-spacing-md group-data-[collapsed=true]/sidebar:flex-col group-data-[collapsed=true]/sidebar:gap-nesra-spacing-lg"> <Sidebar.Logo> <img alt="" src="/logo.png" /> </Sidebar.Logo> <span className="min-w-0 flex-1 group-data-[collapsed=true]/sidebar:hidden"> <span className="block truncate type-nesra-body-small-semibold">Workspace</span> </span> <Sidebar.Trigger /> </Sidebar.Header> );}
export function SidebarNestedExample() { return ( <Sidebar.Provider mobileBreakpoint={0} className="h-[400px] overflow-hidden rounded-nesra-md border border-nesra-stroke-border" > <Sidebar label="Workspace navigation" className="group/sidebar"> <WorkspaceHeader /> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Overview</Sidebar.GroupLabel> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton active render={<a href="#home" aria-label="Home" />} icon={<House />} tooltip="Home" > Home </Sidebar.MenuButton> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.Group> <Sidebar.Group> <Sidebar.GroupLabel>Explore</Sidebar.GroupLabel> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.Collapsible.Root defaultOpen> <Sidebar.Collapsible.Trigger render={ <Sidebar.MenuButton icon={<ChartNoAxesCombined />} tooltip="Analytics" /> } > Analytics <Sidebar.MenuChevron /> </Sidebar.Collapsible.Trigger> <Sidebar.Collapsible.Panel> <Sidebar.MenuSub> <Sidebar.MenuSubItem> <Sidebar.MenuSubButton render={<a href="#reports" aria-label="Reports" />}> Reports </Sidebar.MenuSubButton> </Sidebar.MenuSubItem> <Sidebar.MenuSubItem> <Sidebar.MenuSubButton render={<a href="#trends" aria-label="Trends" />}> Trends </Sidebar.MenuSubButton> </Sidebar.MenuSubItem> </Sidebar.MenuSub> </Sidebar.Collapsible.Panel> </Sidebar.Collapsible.Root> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.MenuButton render={<a href="#guides" aria-label="Guides" />} icon={<BookOpen />} tooltip="Guides" > Guides </Sidebar.MenuButton> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.Group> </Sidebar.Content> <Sidebar.Footer> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton render={<a href="#settings" aria-label="Settings" />} icon={<Settings />} tooltip="Settings" > Settings </Sidebar.MenuButton> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.Footer> </Sidebar> <Sidebar.Inset className="p-nesra-spacing-xl"> <p className="type-nesra-body-small-medium">Choose a destination.</p> </Sidebar.Inset> </Sidebar.Provider> );}Actions and badges
Section titled “Actions and badges”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.
import { Sidebar } from "@nesra/ui/sidebar";import { Bell, Folder, MoreHorizontal, Plus, Settings, Users } from "lucide-react";
function WorkspaceHeader() { return ( <Sidebar.Header className="flex items-center gap-nesra-spacing-md group-data-[collapsed=true]/sidebar:flex-col group-data-[collapsed=true]/sidebar:gap-nesra-spacing-lg"> <Sidebar.Logo> <img alt="" src="/logo.png" /> </Sidebar.Logo> <span className="min-w-0 flex-1 truncate type-nesra-body-small-semibold group-data-[collapsed=true]/sidebar:hidden"> Workspace </span> <Sidebar.Trigger /> </Sidebar.Header> );}
export function SidebarActionsExample() { return ( <Sidebar.Provider mobileBreakpoint={0} className="h-[400px] overflow-hidden rounded-nesra-md border border-nesra-stroke-border" > <Sidebar label="Workspace navigation" className="group/sidebar"> <WorkspaceHeader /> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Workspace</Sidebar.GroupLabel> <Sidebar.GroupAction aria-label="Add workspace item"> <Plus aria-hidden="true" /> </Sidebar.GroupAction> <Sidebar.GroupContent> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton icon={<Bell />} tooltip="Notifications"> Notifications </Sidebar.MenuButton> <Sidebar.MenuBadge>4</Sidebar.MenuBadge> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.MenuButton icon={<Folder />} tooltip="Files"> Files </Sidebar.MenuButton> <Sidebar.MenuAction aria-label="More options for Files" showOnHover> <MoreHorizontal aria-hidden="true" /> </Sidebar.MenuAction> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.MenuButton icon={<Users />} tooltip="Members"> Members </Sidebar.MenuButton> <Sidebar.MenuBadge>12</Sidebar.MenuBadge> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.GroupContent> </Sidebar.Group> </Sidebar.Content> <Sidebar.Footer> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton icon={<Settings />} tooltip="Settings"> Settings </Sidebar.MenuButton> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.Footer> </Sidebar> <Sidebar.Inset className="p-nesra-spacing-xl"> <p className="type-nesra-body-small-medium">Choose an item.</p> </Sidebar.Inset> </Sidebar.Provider> );}Compact items
Section titled “Compact items”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.
import { Sidebar, type SidebarAccount } from "@nesra/ui/sidebar";import { Bell, ChartNoAxesCombined, Folder, House, MoreHorizontal, Settings } from "lucide-react";
const account: SidebarAccount = { id: "irfan", name: "Irfan Yulianto", email: "irfan@nesra.ai", src: "/avatar/portrait.png",};
function WorkspaceHeader() { return ( <Sidebar.Header className="flex items-center gap-nesra-spacing-md group-data-[collapsed=true]/sidebar:flex-col group-data-[collapsed=true]/sidebar:gap-nesra-spacing-lg"> <Sidebar.Logo> <img alt="" src="/logo.png" /> </Sidebar.Logo> <span className="min-w-0 flex-1 truncate type-nesra-body-small-semibold group-data-[collapsed=true]/sidebar:hidden"> Workspace </span> <Sidebar.Trigger /> </Sidebar.Header> );}
export function SidebarCompactExample() { return ( <Sidebar.Provider mobileBreakpoint={0} className="h-[480px] overflow-hidden rounded-nesra-md border border-nesra-stroke-border" > <Sidebar label="Workspace navigation" className="group/sidebar"> <WorkspaceHeader /> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Workspace</Sidebar.GroupLabel> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton active icon={<House />} render={<a href="#home" aria-label="Home" />} size="compact" tooltip="Home" > Home </Sidebar.MenuButton> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.MenuButton icon={<Bell />} render={<a href="#notifications" aria-label="Notifications" />} size="compact" tooltip="Notifications" > Notifications </Sidebar.MenuButton> <Sidebar.MenuBadge>10</Sidebar.MenuBadge> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.MenuButton icon={<Folder />} render={<a href="#files" aria-label="Files" />} size="compact" tooltip="Files" > Files </Sidebar.MenuButton> <Sidebar.MenuAction aria-label="More options for Files" showOnHover> <MoreHorizontal aria-hidden="true" /> </Sidebar.MenuAction> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.Collapsible.Root defaultOpen> <Sidebar.Collapsible.Trigger render={ <Sidebar.MenuButton icon={<ChartNoAxesCombined />} size="compact" tooltip="Analytics" /> } > Analytics <Sidebar.MenuChevron /> </Sidebar.Collapsible.Trigger> <Sidebar.Collapsible.Panel> <Sidebar.MenuSub> <Sidebar.MenuSubButton render={<a href="#overview" aria-label="Overview" />} size="compact" > Overview </Sidebar.MenuSubButton> <Sidebar.MenuSubButton render={<a href="#reports" aria-label="Reports" />} size="compact" > Reports </Sidebar.MenuSubButton> </Sidebar.MenuSub> </Sidebar.Collapsible.Panel> </Sidebar.Collapsible.Root> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.Group> </Sidebar.Content> <Sidebar.Footer> <Sidebar.Menu> <Sidebar.MenuButton icon={<Settings />} render={<a href="#settings" aria-label="Settings" />} size="compact" tooltip="Settings" > Settings </Sidebar.MenuButton> </Sidebar.Menu> <Sidebar.AccountCard account={account} className="mt-nesra-spacing-md" onSignOut={() => {}} /> </Sidebar.Footer> </Sidebar> <Sidebar.Inset className="p-nesra-spacing-xl"> <p className="type-nesra-body-small-medium">Choose a destination.</p> </Sidebar.Inset> </Sidebar.Provider> );}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.
Search and loading
Section titled “Search and loading”Place Sidebar.Input in the header and use Sidebar.MenuSkeleton while destinations are loading.
import { Sidebar } from "@nesra/ui/sidebar";
function SearchHeader() { return ( <Sidebar.Header className="flex flex-col gap-nesra-spacing-lg group-data-[collapsed=true]/sidebar:items-center"> <span className="flex w-full items-center gap-nesra-spacing-md group-data-[collapsed=true]/sidebar:flex-col group-data-[collapsed=true]/sidebar:gap-nesra-spacing-lg"> <Sidebar.Logo> <img alt="" src="/logo.png" /> </Sidebar.Logo> <span className="min-w-0 flex-1 truncate type-nesra-body-small-semibold group-data-[collapsed=true]/sidebar:hidden"> Workspace </span> <Sidebar.Trigger /> </span> <Sidebar.Input aria-label="Search navigation" className="group-data-[collapsed=true]/sidebar:hidden" placeholder="Search navigation" /> </Sidebar.Header> );}
export function SidebarLoadingExample() { return ( <Sidebar.Provider mobileBreakpoint={0} className="h-[400px] overflow-hidden rounded-nesra-md border border-nesra-stroke-border" > <Sidebar label="Loading navigation" className="group/sidebar"> <SearchHeader /> <Sidebar.Separator /> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Recent</Sidebar.GroupLabel> <Sidebar.GroupContent> <Sidebar.Menu> {Array.from({ length: 4 }, (_, index) => ( <Sidebar.MenuItem key={index}> <Sidebar.MenuSkeleton showIcon /> </Sidebar.MenuItem> ))} </Sidebar.Menu> </Sidebar.GroupContent> </Sidebar.Group> </Sidebar.Content> </Sidebar> <Sidebar.Inset className="p-nesra-spacing-xl"> <p className="type-nesra-body-small-medium">Navigation is loading.</p> </Sidebar.Inset> </Sidebar.Provider> );}Mobile drawer
Section titled “Mobile drawer”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.
import { Sidebar } from "@nesra/ui/sidebar";import { BarChart3, House, Menu } from "lucide-react";import { ExampleAccountMenu } from "./account-menu";
export function SidebarMobileExample() { return ( <Sidebar.Provider mobileBreakpoint={9999} className="h-[440px] max-w-[375px] flex-col overflow-hidden rounded-nesra-md border border-nesra-stroke-border" > <Sidebar.MobileHeader> <Sidebar.Logo> <img alt="" src="/logo.png" /> </Sidebar.Logo> <span className="min-w-0 flex-1"> <span className="block truncate type-nesra-body-small-semibold">Platform Name</span> <span className="block truncate type-nesra-body-xsmall-regular text-nesra-text-support"> By Nesra AI </span> </span> <Sidebar.Trigger aria-label="Open navigation"> <Menu aria-hidden="true" size={20} /> </Sidebar.Trigger> </Sidebar.MobileHeader> <Sidebar label="Main navigation" className="group/sidebar"> <Sidebar.Header className="flex items-center gap-nesra-spacing-md pr-14"> <Sidebar.Logo> <img alt="" src="/logo.png" /> </Sidebar.Logo> <span> <span className="block type-nesra-body-small-semibold">Platform Name</span> <span className="block type-nesra-body-xsmall-regular text-nesra-text-support"> By Nesra AI </span> </span> </Sidebar.Header> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Menu</Sidebar.GroupLabel> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton active render={<a href="#mobile-home" aria-label="Home" />} icon={<House />} > Home </Sidebar.MenuButton> </Sidebar.MenuItem> <Sidebar.MenuItem> <Sidebar.Collapsible.Root defaultOpen> <Sidebar.Collapsible.Trigger render={<Sidebar.MenuButton icon={<BarChart3 />} />}> Analytics <Sidebar.MenuChevron /> </Sidebar.Collapsible.Trigger> <Sidebar.Collapsible.Panel> <Sidebar.MenuSub> <Sidebar.MenuSubItem> <Sidebar.MenuSubButton render={<a href="#mobile-overview" aria-label="Overview" />} > Overview </Sidebar.MenuSubButton> </Sidebar.MenuSubItem> <Sidebar.MenuSubItem> <Sidebar.MenuSubButton render={<a href="#mobile-revenue" aria-label="Revenue" />} > Revenue </Sidebar.MenuSubButton> </Sidebar.MenuSubItem> </Sidebar.MenuSub> </Sidebar.Collapsible.Panel> </Sidebar.Collapsible.Root> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.Group> </Sidebar.Content> <Sidebar.Footer> <ExampleAccountMenu side="bottom" /> </Sidebar.Footer> </Sidebar> <Sidebar.Inset className="bg-nesra-foundation-bg-neutral" /> </Sidebar.Provider> );}Composition
Section titled “Composition”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.InsetSidebar.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 mapping
Section titled “Figma mapping”| 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.Logohas 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”.
Light and Dark
Section titled “Light and Dark”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.
Accessibility
Section titled “Accessibility”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.
API reference
Section titled “API reference”Every part accepts the native props for its rendered element plus className, unless noted otherwise.
Sidebar.Provider
Section titled “Sidebar.Provider”| 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.
Sidebar
Section titled “Sidebar”| 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.
Sidebar.Trigger
Section titled “Sidebar.Trigger”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. |
Sidebar.Logo
Section titled “Sidebar.Logo”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.
Sidebar.Inset
Section titled “Sidebar.Inset”Renders the flexible <main> region beside the desktop sidebar.
Sidebar.Input
Section titled “Sidebar.Input”Nesra Input sized for search or filtering inside the sidebar header.
Sidebar.Separator
Section titled “Sidebar.Separator”Horizontal divider between sidebar regions. It renders role="separator".
Sidebar.MobileHeader
Section titled “Sidebar.MobileHeader”Renders a 56px <header> only while the provider is in mobile mode. Place a Sidebar.Trigger here so the closed drawer remains reachable.
Sidebar.Header
Section titled “Sidebar.Header”Fixed region above the scrollable content. Use it for the product or workspace identity.
Sidebar.Content
Section titled “Sidebar.Content”Scrollable region between Sidebar.Header and Sidebar.Footer.
Sidebar.Footer
Section titled “Sidebar.Footer”Fixed bottom region for account controls or persistent actions.
Sidebar.AccountMenu
Section titled “Sidebar.AccountMenu”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.ItemThe application owns the displayed account, selected account, account changes, and application actions. Sidebar.AccountMenu is an alias for Sidebar.AccountMenu.Root.
SidebarAccount
Section titled “SidebarAccount”| 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. |
Sidebar.AccountMenu.Root
Section titled “Sidebar.AccountMenu.Root”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. |
Sidebar.AccountMenu.Trigger
Section titled “Sidebar.AccountMenu.Trigger”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.
Sidebar.AccountMenu.Content
Section titled “Sidebar.AccountMenu.Content”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. |
Sidebar.AccountMenu.Panel
Section titled “Sidebar.AccountMenu.Panel”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.
Sidebar.AccountMenu.ActionGroup
Section titled “Sidebar.AccountMenu.ActionGroup”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.
Sidebar.AccountMenu.Item
Section titled “Sidebar.AccountMenu.Item”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. |
Sidebar.AccountMenu.AccountGroup
Section titled “Sidebar.AccountMenu.AccountGroup”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. |
Sidebar.AccountMenu.AccountItem
Section titled “Sidebar.AccountMenu.AccountItem”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.
Sidebar.AccountMenu.AddAccount
Section titled “Sidebar.AccountMenu.AddAccount”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.
Sidebar.AccountMenu.Footer
Section titled “Sidebar.AccountMenu.Footer”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.
Sidebar.AccountCard
Section titled “Sidebar.AccountCard”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. |
Sidebar.Group
Section titled “Sidebar.Group”Relative container for one related navigation section.
Sidebar.GroupLabel
Section titled “Sidebar.GroupLabel”Section label that becomes visually hidden when the desktop sidebar is collapsed.
Sidebar.GroupAction
Section titled “Sidebar.GroupAction”Optional icon action aligned with the group label. Built on Button; hidden while collapsed.
Sidebar.GroupContent
Section titled “Sidebar.GroupContent”Structural wrapper around a group’s Sidebar.Menu.
Sidebar.Menu
Section titled “Sidebar.Menu”Unordered list for top-level navigation items.
Sidebar.MenuItem
Section titled “Sidebar.MenuItem”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.
Sidebar.MenuButton
Section titled “Sidebar.MenuButton”| 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.
Sidebar.MenuAction
Section titled “Sidebar.MenuAction”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.
Sidebar.MenuBadge
Section titled “Sidebar.MenuBadge”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.
Sidebar.MenuSkeleton
Section titled “Sidebar.MenuSkeleton”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.
Sidebar.MenuSub
Section titled “Sidebar.MenuSub”Indented child-route list. Place it inside Sidebar.Collapsible.Panel.
Sidebar.MenuSubItem
Section titled “Sidebar.MenuSubItem”List item for one child route. Sidebar.MenuSubButton adds it automatically. Write it explicitly when the row needs additional content.
Sidebar.MenuSubButton
Section titled “Sidebar.MenuSubButton”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.
Sidebar.MenuChevron
Section titled “Sidebar.MenuChevron”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
Section titled “Sidebar.Collapsible”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.
useSidebar()
Section titled “useSidebar()”Returns shadcn-compatible state, open, setOpen, isMobile, openMobile, setOpenMobile, and toggleSidebar values inside Sidebar.Provider. Routing remains the consuming application’s responsibility.