Sidebar

React application sidebar with groups, menus, sub-menus, badges, and a collapsible icon rail on desktop that becomes a drawer on mobile. Flips sides in RTL.

Wrap the app in SidebarProvider, then place a Sidebar and a SidebarInset. It collapses to an icon rail on desktop and a drawer on mobile, and flips sides in RTL.

When to use

Use Sidebar as the primary navigation of an authenticated application: an admin console, a case management tool, or a citizen dashboard with several sections. Wrap the app in SidebarProvider, place the Sidebar, and render pages inside SidebarInset.

For public sites with a few links, a header with SlideoutMenu on mobile is lighter.

Examples

App shell

Props

Props declared by Sidebar. Native attributes of the underlying element pass through.

<Sidebar>

PropTypeDefaultDescription
variant"sidebar" | "floating" | "inset"
collapsible"icon" | "none" | "offcanvas"
side"start" | "end"Logical side; flips with dir. Default 'start'.

<SidebarProvider>

PropTypeDefaultDescription
defaultOpenbooleanUncontrolled initial desktop state. Default true (expanded).
openbooleanControlled desktop open state.
onOpenChange(open: boolean) => void
mobileBreakpointnumberViewport width (px) below which the mobile Drawer engages. Default 768.
keyboardShortcutbooleanRegister Cmd/Ctrl+B to toggle. Default true.

<SidebarTrigger>

PropTypeDefaultDescription
asChildboolean

<SidebarInset>

PropTypeDefaultDescription
asChildboolean
scrollablebooleanMake the inset its own vertical scroll region: tall content scrolls inside it (the sidebar + footer stay put) with zero consumer layout CSS - no flex / min-block-size:0 / overflow-y:auto boilerplate. The whole inset scrolls, header included; for a fixed header with only the body scrolling, leave this off and compose a nested scroll region inside the inset (see the App shell story).

<SidebarGroupAction>

PropTypeDefaultDescription
asChildboolean

<SidebarMenuButton>

PropTypeDefaultDescription
size"sm" | "md" | "lg"
asChildboolean
isActiveboolean
tooltipreact.ReactNodeTooltip content shown only when the rail is collapsed (desktop).

<SidebarMenuAction>

PropTypeDefaultDescription
asChildboolean
showOnHoverbooleanReveal the action only on row hover/focus (CSS-driven).

<SidebarMenuSkeleton>

PropTypeDefaultDescription
showIconboolean

<SidebarMenuSubButton>

PropTypeDefaultDescription
size"sm" | "md"
asChildboolean
isActiveboolean

Accessibility

Menus render as lists of buttons and links, and the active item is marked with aria-current. Collapsible groups expose aria-expanded. When collapsed to the icon rail, each item shows a tooltip so the label is still available.

The trigger has an accessible name, and SidebarProvider offers a keyboard shortcut you can set with keyboardShortcut. On mobile, the sidebar opens as a drawer with focus trapping.