Sidebar
npx shadcn add https://ui.klarhimmel.com/r/sidebar.jsonCopy for AIDetailsAbout, usage, props and more
An app's side navigation: a brand row, search, items with counts, groups that open and close, a foot. Works rendered on the server with no script.
When to use
Use for
The main navigation of an app or dashboard, also on pages rendered on the server with no script.
Not for
A marketing site header. Use the navigation blocks.
Pairs with
SidebarLayout for the shell; Input in SidebarSearch; Badge counts.
Preview
Import
Import
- Files
- sidebar.tsx, sidebar.css, in components/klarhimmel/ui/. With it: theme, tooltip, utils. npm: lucide-react.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Anatomy
The parts and how they nest.
SidebarLayoutThe shell: a container, sidebar column from 56rem.SidebarGroupA native disclosure with counts.SidebarItemA 44 px link row; current = tint, bar and weight.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
Sidebar.header | ReactNode | - | Always shown, also when the rest folds away (the brand row). |
Sidebar.foldLabel | ReactNode | - | Inside SidebarLayout: the menu button's name under 56rem ("Menu"); the button opens the navigation as a drawer. Without it the sidebar stays above the content on a narrow screen. |
Sidebar.closeLabel | ReactNode | 'Close menu' | The same button's name while the drawer is open (it shows an X then). Default "Close menu". |
Sidebar.rail | boolean | false | A narrow rail of icons: item and group names go to screen readers and tooltips. |
Sidebar.children | ReactNode | required | |
SidebarLayout.sidebar | ReactNode | - | The <Sidebar>: beside the content from 56rem of this layout's width (sticky, full height), above it when narrower. |
SidebarLayout.children | ReactNode | required | |
SidebarLayout.frame | 'panels' | 'flush' | 'panels' | 'panels' (default; Felix 2026-10-22 14:4x "we make it the default look for all our apps"): from 64rem the sidebar and the content are rounded panels floating on a soft canvas with an even gap (sidebar.css, --kh-shell-* variables). 'flush': the sidebar column against the window edge with a line, as before. Phones keep the top bar and drawer either way. |
SidebarLayout.focus | boolean | false | A focus page (a task, a board): no sidebar, the work gets the whole width. |
SidebarLayout.bar | ReactNode | - | A top bar over the content (a focus page's way back, title and actions): its own floating panel in the panels frame. |
SidebarLayout.barFlush | boolean | false | The bar is one element of the app's own that fills the bar's panel edge to edge (its own surface and padding): no padding or line from the shell, its corners follow the panel's. |
SidebarLayout.bareContent | boolean | false | No content panel: the work sits on the canvas and draws its own panels (a board's columns). Panels frame only. |
SidebarLayout.barOpen | boolean | false | The bar on the canvas with no panel of its own (a board's title and zoom over its columns, Felix 28 Oct: "the title on the canvas with no panel, so the columns carry the eye"). Panels frame only. |
SidebarLayout.scrollKey | string | - | The page's address (a route or hash). In the panels frame from 64rem the content panel scrolls, not the window, so a host's scrollTo(0, 0) on navigation misses it: when this changes, the content panel goes back to its top. |
SidebarHeader.action | ReactNode | - | |
SidebarNav.label | string | - | Names the navigation landmark. Not shown. (Or aria-labelledby.) |
SidebarMenu.inset | boolean | - | An accent count, a quiet count, and indented items for plain text links. |
SidebarGroup.label | ReactNode | required | |
SidebarGroup.collapsible | boolean | true | false: a fixed heading, always open. |
SidebarGroup.defaultOpen | boolean | - | Whether a collapsible group starts open (a native <details>, no script needed). |
SidebarGroup.open | boolean | - | Controlled instead: a button with aria-expanded, for an app that keeps the state itself. Needs onOpenChange. |
SidebarGroup.onOpenChange | (open: boolean) => void | - | |
SidebarGroup.badge | ReactNode | - | A leading icon, an accent count that wants attention, a quiet count at the end. |
SidebarGroup.meta | ReactNode | - | An accent count, a quiet count, and indented items for plain text links. |
SidebarGroup.inset | boolean | - | Indent the items under the heading (groups of plain text links, no icons). |
SidebarGroup.children | ReactNode | required | |
SidebarItem.href | string | required | |
SidebarItem.current | boolean | - | The page the person is on: aria-current, a soft fill and a heavier weight (never the fill alone); no bar at the side at any width (Felix 2026-10-21 16:2x). |
SidebarItem.icon | ReactNode | - | |
native attributes | HTMLAttributes | - | Every native attribute of the element passes through, className included. |
Accessibility
| Key | Does |
|---|---|
Tab | Moves through the links and the group headings. |
Enter or Space on a group heading | Opens or closes the group. |