← All Components

Sidebar

Full-featured sidebar with collapsible states, keyboard shortcuts, sub-menus, badges, and mobile Sheet support. The most complex compound component.

Default (Icon Collapsible)

Press Cmd+B to toggle. Collapses to icon-only mode.

Dashboard
Main content area. Use Cmd+B to toggle sidebar.

With Sub-Menus and Badges

Full Featured
Sidebar with sub-menus, badges, multiple groups, and footer actions.

Sub-Components

Sub-ComponentDescription
Sidebar.ProviderContext provider with keyboard shortcut (Cmd+B)
Sidebar.TriggerToggle button for the sidebar
Sidebar.RailThin draggable rail to toggle sidebar
Sidebar.InsetMain content area next to the sidebar
Sidebar.HeaderTop section with branding
Sidebar.ContentScrollable content area
Sidebar.FooterBottom section
Sidebar.GroupGroups menu items together
Sidebar.GroupLabelLabel for a group
Sidebar.GroupContentContent wrapper for a group
Sidebar.MenuMenu list container
Sidebar.MenuItemIndividual menu item wrapper
Sidebar.MenuButtonClickable button within a menu item
Sidebar.MenuBadgeBadge/count indicator on a menu item
Sidebar.MenuSubSub-menu container
Sidebar.MenuSubItemSub-menu item wrapper
Sidebar.MenuSubButtonClickable button within a sub-menu
Sidebar.InputSearch input for the sidebar

Props

PropTypeDescription
side"left" | "right"Which side the sidebar appears on
variant"sidebar" | "floating" | "inset"Visual style variant
collapsible"offcanvas" | "icon" | "none"Collapse behavior
defaultOpenbooleanInitial open state (Provider prop)
openbooleanControlled open state (Provider prop)
onOpenChange(open: boolean) => voidOpen state change handler (Provider prop)

Usage

import { Sidebar } from "@/components/ui/Sidebar"; import { Home, Settings } from "lucide-react"; <Sidebar.Provider> <Sidebar side="left" collapsible="icon"> <Sidebar.Header> <span className="font-head">My App</span> </Sidebar.Header> <Sidebar.Content> <Sidebar.Group> <Sidebar.GroupLabel>Nav</Sidebar.GroupLabel> <Sidebar.GroupContent> <Sidebar.Menu> <Sidebar.MenuItem> <Sidebar.MenuButton tooltip="Home"> <Home /> <span>Home</span> </Sidebar.MenuButton> </Sidebar.MenuItem> </Sidebar.Menu> </Sidebar.GroupContent> </Sidebar.Group> </Sidebar.Content> </Sidebar> <Sidebar.Inset> <Sidebar.Trigger /> <main>Content here</main> </Sidebar.Inset> </Sidebar.Provider>