Skip to content
GitHub

Sidebar

A sidebar for navigation and app structure.

For full-page examples that wire the sidebar into dashboards, media apps, and other shells:

Browse the Sidebar Components (soon).

Installation

Structure

Piecing a Sidebar together usually means:

  • <SidebarProvider> — Owns open/collapsed state, mobile sheet state, and keyboard shortcut handling.
  • <Sidebar> — Fixed (or sheet) column: placement, variant, and collapsible behavior.
  • <SidebarHeader> / <SidebarFooter> — Pin content to the top or bottom of the column.
  • <SidebarContent> — Scrollable middle; optional scrollFade on the inner scroll area.
  • <SidebarGroup> — Labeled section inside the scroll region.
  • <SidebarTrigger> — Icon/control wired to useSidebar().toggleSidebar.
  • <SidebarInset> — Main document column beside the sidebar (required for variant="inset").

Optional helpers: <SidebarRail> (edge hit target), the <SidebarMenu> building blocks (submenus, badges, skeletons, actions)—same roles as in the upstream doc.

Usage

app/layout.tsx keeps the provider at the top level:

TypeScriptapp/layout.tsx

The sidebar column itself is usually a dedicated module:

TypeScriptcomponents/app-sidebar.tsx

Controlled

Use the onOpenChange prop to control the sidebar open state.

Theming

Sidebar uses CSS variables to style the sidebar. See the full palette in Colors.

Variable Reference

  • --sidebar — Sidebar background
  • --sidebar-foreground — Sidebar text
  • --sidebar-primary — Active item background
  • --sidebar-accent — Hover and active states
  • --sidebar-border — Sidebar borders
  • --sidebar-ring — Focus rings

Learn more about styling in the Styling section.

Styling

React to collapse mode and peer state with utilities.

Keyboard shortcut

The toggle listens for ⌘B on macOS and Ctrl+B elsewhere (SIDEBAR_KEYBOARD_SHORTCUT in source). Match that expectation in shortcuts or help copy.

API Reference

SidebarProvider

<SidebarProvider /> must wrap any tree that calls useSidebar or renders <Sidebar /> / <SidebarTrigger />. It forwards standard div props (including className and style).

Width

Defaults live beside SIDEBAR_WIDTH and SIDEBAR_WIDTH_MOBILE inside the registry file. Override per layout with CSS variables on the provider:

Primary column component: desktop fixed strip + mobile sheet (via Sheet).

Collapsible modes

With variant="inset", park page content in SidebarInset so padding, radius, and background line up with the inset shell:

useSidebar

SidebarHeader

Sticky top region—common pattern: workspace switcher or brand row inside a SidebarMenu.

Wire menus or Menu triggers to SidebarMenuButton as needed.

SidebarFooter

Sticky bottom slot—profile, settings entry, sign-out, etc.

SidebarContent

Wraps scrollable groups. Pass scrollFade when you want a fade on vertical overflow (see component props in source).

SidebarGroup

A titled block with optional <SidebarGroupAction /> and <SidebarGroupContent />.

Collapsible groups pair with Collapsible. <SidebarGroupLabel /> is a plain label slot—keep the trigger beside it (or fold the pattern into <SidebarMenu /> like the preview at the top of this page):

SidebarMenu

Row list inside a group—map data to <SidebarMenuItem /> / <SidebarMenuButton />.

SidebarMenuButton

Default renders a Button; use asChild for links. isActive highlights the active route; tooltip surfaces collapsed labels.

SidebarMenuAction

Icon-only or compact action aligned to a row (e.g. “add”, “more”). Use showOnHover to reveal on row hover.

SidebarMenuSub

Nested list hanging off a parent item.

SidebarMenuBadge

Small count or pill beside a row.

SidebarMenuSkeleton

Placeholder rows while async routes or prefs load.

SidebarTrigger

Prebuilt toggle wired to context—drop next to your page title or in a toolbar.

Prefer <SidebarTrigger /> when you want the default styling and accessibility bundle.

SidebarRail

Draggable edge control that expands or collapses the desktop rail—place after header/content/footer inside <Sidebar />.