Sidebar
A collapsible side navigation column with header, body, footer, grouped items, and automatic mobile-drawer behaviour.
Renders an aside containing a labelled nav landmark; items expose aria-current; tooltips replace labels when collapsed to the icon rail; the mobile drawer is fully focus-trapped.
import { Sidebar, SidebarProvider, SidebarHeader, SidebarBody, SidebarFooter, SidebarNav, SidebarGroup, SidebarItem, SidebarSeparator, SidebarTrigger,} from "@arshad-shah/cynosure-react";
<SidebarProvider> <Sidebar> <SidebarHeader>App</SidebarHeader> <SidebarBody> <SidebarNav aria-label="Primary"> <SidebarGroup label="Workspace"> <SidebarItem icon={<DashboardIcon />} label="Dashboard" isActive /> <SidebarItem icon={<InboxIcon />} label="Inbox" badge="12" /> </SidebarGroup> </SidebarNav> </SidebarBody> <SidebarFooter>v1.0.0</SidebarFooter> </Sidebar></SidebarProvider>SidebarProvider owns collapsed and mobile-open state. On viewports matching mobileQuery (default (max-width: 47.99em)) the sidebar renders inside a Drawer automatically; on desktop it collapses to an icon rail when collapsible="icon" (the default).
Variants
Section titled “Variants”Collapsible icon rail
Section titled “Collapsible icon rail”Use SidebarTrigger anywhere to toggle the collapsed state. When collapsed, item labels are hidden but tooltips reveal them on hover.
Groups with collapsible sections
Section titled “Groups with collapsible sections”Pass collapsible to SidebarGroup (with optional defaultOpen) for accordion-style sections. An action slot beside the label is useful for a ”+” button.
Sub-navigation
Section titled “Sub-navigation”Use SidebarSubNav to nest items under a parent. When the rail is collapsed, sub-navs automatically render as a flyout Popover triggered by the parent item.
Right-aligned sidebar
Section titled “Right-aligned sidebar”Pass side="right" to SidebarProvider (or directly to Sidebar) to mirror the layout.
Variants — sidebar, floating, inset
Section titled “Variants — sidebar, floating, inset”The variant prop on SidebarProvider adjusts the surface treatment: "sidebar" (default) sits flush, "floating" is detached with a shadow, "inset" is recessed inside the page background.
With footer actions
Section titled “With footer actions”SidebarFooter is a free-form slot — use it for user menus, version pills, or upgrade prompts.
Accessibility
Section titled “Accessibility”- The sidebar renders as
<aside>containing a<nav>(SidebarNav); passaria-labeltoSidebarNavfor an explicit landmark name. SidebarItemcarriesaria-current="page"whenisActiveis set, andaria-disabled="true"whendisabled.- A roving
tabindexis implemented internally (useRovingFocus) so arrow keys move between sidebar items without trappingTab. - When the rail is collapsed (icon-only mode), each
SidebarItemis automatically wrapped in aTooltipthat announces its label. - On mobile, the sidebar renders inside a
Drawerwith a hidden title (mobileTitle, default"Sidebar") so screen readers can identify the dialog. SidebarTriggertogglesaria-expandedandaria-pressedand updates its accessible name ("Expand"/"Collapse"/"Open"/"Close") automatically.
Recipes
Section titled “Recipes”- Wrap your whole app in
SidebarProviderso the collapsed state persists across routes. - Use
collapsible="offcanvas"instead of"icon"when you want the desktop sidebar to slide away entirely rather than shrink to a rail. - Pair
SidebarItem asChildwith a router<Link>to keep client-side navigation while inheriting the styled chrome. - Set
tooltip={false}on items that already have an obvious meaning when collapsed (e.g. avatars). - Use
variant="floating"for marketing-style dashboards andvariant="inset"when the sidebar should look set into the page background.