Sidebar

A collapsible sidebar for app navigation with groups, nested items, active states and badges. When collapsed the labels are visually hidden but stay in the DOM for screen readers, with aria-current / aria-expanded semantics.

Props

PropTypeDefaultDescription
collapsedboolean—Controlled collapsed state
defaultCollapsedbooleanfalseInitial collapsed state when uncontrolled
onCollapsedChange(collapsed: boolean) => void—Called whenever the collapsed state changes
collapsiblebooleantrueWhether collapsing is allowed; the Trigger is disabled when false
activestring—Controlled active value
defaultActivestring''Initial active value when uncontrolled
onActiveChange(value: string) => void—Called on every active change, controlled or not
SidebarProvidercomponent—Lifts the collapse and active state outside Sidebar so external buttons such as a top bar can share it; takes the same state props as Sidebar
useSidebar()hook—Reads collapsed / active and exposes toggleCollapsed; callable inside Sidebar or SidebarProvider
Sidebar.HeaderHTMLAttributes—Top area; only the Trigger remains when collapsed
Sidebar.ContentHTMLAttributes—The scrollable navigation body, rendered as <nav>
Sidebar.GroupHTMLAttributes—A group container with an optional label and icon
Group.labelReactNode—Group label, hidden when collapsed
Group.iconReactNode—Group icon, kept when collapsed
Sidebar.ItemHTMLAttributes—A nav item; becomes an expandable parent when it contains a Sub
Item.valuestring—Unique value matched against the active value on the root
Item.iconReactNode—Leading icon
Item.badgeReactNode—Trailing badge or count
Item.activeboolean—Force the active state, overriding the root active match
Item.disabledboolean—Disabled items cannot be activated
Item.hrefstring—Render as an <a> link
Item.asChildbooleanfalseMerge behaviour onto the only child (e.g. a router Link); leaf items only
Sidebar.SubHTMLAttributes—The sub-navigation container; its open state comes from the parent Item
Sidebar.SubItemHTMLAttributes—A second-level item with the same props as Item
Sidebar.SeparatorHTMLAttributes—A divider
Sidebar.FooterHTMLAttributes—Bottom area; only the Trigger remains when collapsed
Sidebar.TriggerHTMLAttributes—The collapse toggle that flips collapsed
Trigger.asChildbooleanfalseSkip the built-in button and merge behaviour onto the only child
Trigger.expandLabelstring—Accessible name of the button while collapsed
Trigger.collapseLabelstring—Accessible name of the button while expanded