Sidebar
v0.64.0, changelogBetaA console's main navigation: grouped links with counts, tags and nested pages, a switcher header and an account footer, collapsing to an icon rail (⌘B / Ctrl+B) and a sheet on phones.
API reference
Generated from the types. Every part also takes className.
SidebarProvider
Also takes every prop of <div>.
- defaultOpen
boolean = trueOpen at first on wide screens, until someone toggles it (uncontrolled). A stored choice (the cookie) wins over it.- open
booleanOpen on wide screens, controlled; pair with onOpenChange.- onOpenChange
(open: boolean) => void- defaultOpenMobile
boolean = falseThe phone sheet open at first, for previews and tests.- isMobile
booleanThe phone (sheet) or desktop (column) form, instead of following the screen's width (768 px): for a preview frame.- cookieName
string | null = SIDEBAR_COOKIE_NAMEThe cookie that keeps the choice for a week (and<name>_widththe width). null keeps them for this page only.- defaultWidth
number = WIDTH.startThe open column's width at first, in px (200 to 320, default 240). A stored width (the cookie) wins over it.- keyboardShortcut
string | false = "mod+b"Toggles the sidebar from anywhere on the page, except while typing. mod is ⌘ on a Mac, Ctrl elsewhere; false for none.- labels
Partial<SidebarLabels>
Sidebar
Also takes every prop of <aside>.
- side
"left" | "right" = "left"- variant
"floating" | "sidebar" = "sidebar"sidebar (default): a column with a hairline beside the page. floating: a raised panel (give the providergap-2; SidebarRail sits in the 8 px gap).p-2 - collapsible
"none" | "icon" | "offcanvas" = "icon"icon (default): collapses to a 68 px rail of icons with tooltips. offcanvas: collapses out of view. none: always open.
SidebarTrigger
Also takes every prop of <button>.
- show
"collapsed" | "always" | "expanded" | "mobile" = "always"When it shows. always (default): one trigger that collapses and expands, wherever it is. The pair that puts the collapse control on the sidebar: "expanded" in SidebarHeader (shown while the sidebar is open on a wide screen, never on phones, where the sheet has its own close) and "collapsed" in the page's top bar (shown while the sidebar is a rail or hidden, and always on phones, where it is the menu button that opens the sheet). "mobile": only on phones, the menu button that opens the sheet, for a layout whose wide screens collapse and expand at the sidebar's edge (SidebarRail) instead.
SidebarMenuButton
Also takes every prop of <button>.
- asChild
boolean = falseRender your link (a, next/link) instead of a button, with the button's look.- isActive
boolean = falseThe current page: the kit's current look (muted fill and weight) and aria-current="page".- size
"sm" | "md" | "lg" = "md"- tooltip
ReactNode | (TooltipContentProps & RefAttributes<HTMLDivElement>)Shown beside the rail when the sidebar is collapsed: the link's name, or TooltipContent props.
SidebarMenuBadge
- countrequired
number- max
number- tone
"neutral" | "danger" = "danger"
SidebarMenuSubButton
Also takes every prop of <a>.
- asChild
boolean = false- isActive
boolean = false
Other parts
SidebarRail,SidebarInset,SidebarHeader,SidebarFooter,SidebarGroup,SidebarGroupLabelandSidebarGroupContenttake every prop of<div>.SidebarSeparatortakes every prop of<hr>.SidebarContenttakes every prop of<nav>.SidebarMenuandSidebarMenuSubtake every prop of<ul>.SidebarMenuItemandSidebarMenuSubItemtake every prop of<li>.SidebarMenuTagtakes every prop of<span>.