Sidebar
App shell navigation beside the page: a column of sections and items from the start edge, with a trigger that collapses it to a rail of icons (each named by a Tooltip) or hides it. Below the md breakpoint the same content opens in a Sheet. The optional panel variant adds a brand header with an internal toggle and nested navigation groups. With inset, the column sits on the sunken canvas and SidebarInset holds the page content in one page-filled panel.
Preview
Usage
When to use
- Top-level navigation that stays beside the page across a whole product.
- A long list of destinations grouped into named sections.
When not to use
- Switching between views of the same content. Use Tabs.
- A short list of actions anchored to a control. Use DropdownMenu.
- One optional section on a page. Use Accordion.
Variants
collapsible
Set on SidebarProvider. icon keeps a rail of icons with Tooltips when collapsed; offcanvas hides the sidebar on desktop entirely without SidebarBrand, or keeps the internal recovery toggle with it; none fixes it open.
side
Set on SidebarProvider. The edge the sidebar sits on; the Sheet opens from the same edge.
variant
Set on Sidebar. default keeps the flat navigation example; panel adds nested groups. With SidebarBrand, both variants keep the toggle inside the header, replacing the logo on the collapsed or mobile rail.
Examples
App navigation
Offcanvas with a trigger
collapsible offcanvas hides the sidebar on desktop; the trigger toggles it and opens the Sheet on a small screen.
Panel with brand header
The internal header toggle sits beside a placeholder logo. Nested groups expand in place; the compact rail and mobile sheet keep navigation accessible.
Inset layout
The app layout: the Sidebar on the sunken canvas and the page content in one inset panel with 32px padding.
Do and don't
Do
- Give every section a label; it names the nav and orients the reader.
- Mark exactly one item active, the page the user is on.
- Keep the footer for identity and account actions, not navigation.
- Use SidebarBrand inside SidebarHeader in either variant so the toggle remains inside the sidebar.
- Give every SidebarGroup a label and leading icon. Use nested SidebarItem links for destinations.
- Use item values with SidebarProvider defaultValue for button destinations that select views without links. Use value and onValueChange when the application controls selection.
- Keep submenu destinations in SidebarGroup so panel rails can expose them in a side flyout.
- In an app, set inset on the Sidebar and put the page content in SidebarInset. Its padding is the page padding: don't pad the content again, and separate sections with gap-2xl.
Don't
- Don't switch between views of the same content; use Tabs.
- Don't put controls other than items inside the content; put them in the header or footer.
- Don't nest a sidebar inside a sidebar.
- Do not use offcanvas without SidebarBrand unless an external opener remains accessible.
- Don't put a Card around the whole page inside SidebarInset; it already is the panel. Cards inside it keep their surface fill and border.
Props
| Name | Type | Values | Default | Description |
|---|---|---|---|---|
| collapsed | boolean | - | - | Set on SidebarProvider. The collapsed state, when you control it. Pair it with onCollapsedChange. |
| defaultCollapsed | boolean | - | false | Set on SidebarProvider. Collapsed on first render. |
| onCollapsedChange | function | - | - | Set on SidebarProvider. Called with the next collapsed state. |
| collapsible | enum | icon | offcanvas | none | icon | Set on SidebarProvider. icon keeps a rail of icons with Tooltips when collapsed; offcanvas hides the sidebar on desktop entirely without SidebarBrand, or keeps the internal recovery toggle with it; none fixes it open. |
| side | enum | left | right | left | Set on SidebarProvider. The edge the sidebar sits on; the Sheet opens from the same edge. |
| label | string | - | Main | Set on SidebarContent, the name of its navigation landmark; set on SidebarSection, the group's heading and name (hidden on the icon rail). |
| active | boolean | - | false | Set on SidebarItem. The page this item points to: aria-current="page", the muted accent fill with its strong text, and the fill icon weight. When omitted on an item with value, selection comes from SidebarProvider. An explicit active prop overrides that item's selected state. |
| asChild | boolean | - | false | Set on SidebarItem. Renders the item as the single child element, typically a router link. |
| href | string | - | - | Set on SidebarItem. With it the item is a link; without it a button. |
| count | number | - | - | Set on SidebarItem. A number after the label in a Badge; on the rail it moves into the Tooltip. |
| leadingIcon | node | - | - | Set on SidebarItem. The Tabler icon before the label, 20px. |
| leadingIconOn | node | - | - | Set on SidebarItem. The filled-variant icon (Tabler *Filled, e.g. IconHomeFilled) shown on the active item instead of leadingIcon. |
| disabled | boolean | - | false | Set on SidebarItem. The item cannot activate and dims, including links and slotted router links. Disabled items leave the tab order; on the icon rail their Tooltip still opens on hover. |
| variant | enum | default | panel | default | Set on Sidebar. default keeps the flat navigation example; panel adds nested groups. With SidebarBrand, both variants keep the toggle inside the header, replacing the logo on the collapsed or mobile rail. |
| name required | string | - | - | Set on SidebarBrand. The required workspace name, visually hidden on the rail. |
| logo | node | - | - | Set on SidebarBrand. A custom logo node; omitted, it shows a neutral placeholder. |
| open | boolean | - | - | Set on SidebarGroup. Controls the expanded sidebar's inline disclosure; pair with onOpenChange. The collapsed panel's transient hover flyout has independent state. |
| defaultOpen | boolean | - | false | Set on SidebarGroup. Starts the inline disclosure open. It does not open the collapsed panel flyout. |
| onOpenChange | function | - | - | Set on SidebarGroup. Called with the requested inline disclosure state. Transient panel flyout changes do not call it. |
| value | string | - | - | Set on SidebarProvider for controlled selection, paired with onValueChange. Set on SidebarItem to identify that destination. Activating an enabled item updates selection; href remains optional. |
| defaultValue | string | - | - | Set on SidebarProvider. The initially selected item value when selection is uncontrolled. |
| onValueChange | function | - | - | Set on SidebarProvider. Called once when an enabled item requests a different selected value. |
| inset | boolean | - | false | Set on Sidebar. Puts the column on the sunken canvas with no visible edge, for an app layout where SidebarInset holds the page content. Independent of variant. |
| sheetTitle | string | - | Sidebar | Set on Sidebar. Names the Sheet below md. Without a SidebarBrand it also shows beside the Sheet's close button, so the reader knows which menu is open. |
Slots
| Name | Required | Description |
|---|---|---|
| header | no | SidebarHeader above the scrolling content. |
| content | yes | SidebarContent with one or more SidebarSection of SidebarItem. |
| footer | no | SidebarFooter pinned at the end. |
| inset | no | SidebarInset beside the Sidebar, with the page content. |
Anatomy
| Part | Description |
|---|---|
| root | Sidebar: the desktop column, hidden below md, 256px wide, bordered only on the edge that faces the content. On the icon rail it is one square md item wide plus spacing-sm on each side (49px with the border on mouse, 53px on touch), and the header, content and footer pad with spacing-sm. With SidebarBrand, either variant uses one md control width on the rail and keeps a compact rail visible below md so the internal toggle remains accessible. |
| header | SidebarHeader: the block above the scrolling content, such as the workspace name. |
| content | SidebarContent: the scrolling group of sections, a nav named by its label (default "Main"). |
| footer | SidebarFooter: the block pinned at the end, with a Separator above it. |
| section | SidebarSection: a group of related items, named by its label, with the items in a list. |
| label | The section heading: 12px medium secondary text, hidden on the icon rail. |
| item | SidebarItem: one destination, a link with href, a button without one, or any element with asChild. At least the md control height, 14px medium text, a Badge after the label with count. Inline padding is spacing-sm, and grows with the corner up to half the row height so a pill cap does not cover the label. On the icon rail an item with an icon is a square of the md control height. |
| current | The active item, the page the user is on: the muted accent fill with its strong text. |
| currentIcon | The active item's icon in the accent icon color, at the fill weight. |
| icon | The item's leading Tabler icon at 20px; leadingIconOn (the *Filled variant) replaces it on the active item. |
| trigger | SidebarTrigger: one ghost icon button that collapses the sidebar on md and up and opens the Sheet below it, named by its label. With collapsible none it shows only below md. |
| brand | SidebarBrand: a placeholder or supplied logo and the workspace name beside SidebarTrigger when expanded. On the rail the logo is removed and the toggle takes its place, aligned with the navigation icons. The logo returns when expanded, including in the mobile Sheet. |
| group | SidebarGroup: a named disclosure button with a leading icon and caret, followed by a list of nested destinations. Its children hide on the rail; activating it expands the sidebar, or opens the mobile sheet. On a collapsed desktop panel, hover or activate its icon to open the destinations in a side flyout toward the page, without expanding the sidebar. The flyout reuses Popover positioning, collision handling and motion. |
| inset | SidebarInset: the page content beside an inset Sidebar, a main landmark that scrolls on its own. From md up it is one page-filled panel with the page radius and a border, spacing-sm from the canvas edges, padded spacing-2xl (32px). Below md the Sidebar is a Sheet, so it runs full bleed with spacing-lg padding plus the bottom safe area. An inset Sidebar takes the sunken fill and a transparent edge. |
Accessibility
Role: complementary
| Keys | Action |
|---|---|
| Tab | Moves from item to item; items are links or buttons in the page order. |
| Enter, Space | A button item activates; a link item follows its href. |
| Escape | Closes the Sheet the sidebar becomes on a small screen. |
- The root is an aside (complementary). SidebarContent inside it is the one navigation landmark, named by its label (default "Main").
- Each SidebarSection is a group named by its visible label (aria-labelledby), or by aria-label on the icon rail where the label is hidden. Its items are a list.
- The current page's item sets aria-current="page" and its icon switches to the fill weight; the state never relies on color alone.
- On the rail an item with an icon moves its label into a Tooltip and an sr-only span. Items without icons keep visible text. A disabled item stays out of the tab order, and its Tooltip still opens on hover. Mobile sheets always show full labels.
- The Sheet names itself with an sr-only title; the trigger button carries the same name in aria-label.
- Without a SidebarBrand the Sheet puts its Close sidebar button in a row of its own above the content, so the first item never sits under it.
- Sidebar parts must sit inside a SidebarProvider; without it they throw.
- SidebarBrand names the internal trigger by its action: Collapse sidebar, Expand sidebar or Close sidebar. The panel mobile rail opens the Sheet; the Sheet header closes it and returns focus to the original opener.
- SidebarGroup exposes aria-expanded and aria-controls. Closed groups and groups on the rail remove their nested destinations from keyboard navigation. Group open state survives sidebar collapse.
- With a brand header, offcanvas hides navigation while keeping the internal recovery button on the rail, with the logo hidden. Without a brand header, the existing offcanvas behavior hides the whole column and needs an external opener.
- On the collapsed rail SidebarBrand removes the decorative logo and keeps the toggle in its place. The toggle stays mounted so keyboard focus survives collapse and expansion.
- Button destinations with value share one selection through SidebarProvider; controlled selection changes only when the supplied value changes. Disabled items cannot request selection. Selection persists between the desktop rail and mobile Sheet.
- Collapsed panel group flyouts open on hover without moving focus. Click or keyboard activation moves focus into the flyout; Escape dismisses it. Selecting a destination closes it and preserves the collapsed rail. Default rail groups and mobile groups keep their existing expansion behavior.
Install
npx werewolf-ui add sidebarRun npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.