ui-kit0.0

Navigation

Sidebar

Collapsible app sidebar.

Usage

Wrap the page in SidebarProvider, put a Sidebar next to a SidebarInset and build the menu from groups, rows and optional nested items. Press Ctrl + B (or the trigger) to collapse it to an icon rail; the label of each row appears in a tooltip while it is collapsed. The state is remembered between visits.

Dashboard

Active users

8,402

+4.1% this week

MRR

$48,920

+$2,140 this month

Open tickets

37

9 waiting on you

Press Ctrl + B to collapse or expand the sidebar.

When to use

  • Apps with more than five destinations, or destinations with sub-pages.
  • Tools people stay in all day, where the navigation should always be one click away.

Not for: marketing sites (use a navbar) or a handful of tabs inside one page (use tabs).

Full page and framed

On a full page the sidebar is sticky and as tall as the screen. Add framed to SidebarProvider and give it a height to lay it out inside a card or a docs preview; the inset then scrolls on its own. Below 768px (mobileBreakpoint) the same content opens as an off-canvas sheet.

Off-canvas

collapsible="offcanvas" slides the sidebar away completely instead of leaving a rail. collapsible="none" never collapses on desktop.

Getting started

This sidebar slides away completely instead of shrinking to an icon rail.

API

SidebarProvider

PropTypeDefaultDescription
open / defaultOpen / onOpenChangeboolean / boolean / (open) => voiddefaultOpen: trueDesktop state: expanded or collapsed.
storageKeystring | false'ui-sidebar'localStorage key that remembers the state. Wrapped in try/catch; false turns it off.
shortcutbooleantrueCtrl / Cmd + B toggles. Ignored while typing in a field.
mobileBreakpointnumber768Viewport width under which the sidebar is a sheet.
framedbooleanfalseLay out inside a fixed-height container instead of the page.

Sidebar

PropTypeDefaultDescription
side'left' | 'right''left'Edge it sits on.
collapsible'icon' | 'offcanvas' | 'none''icon'What collapsing does.

SidebarMenuButton

PropTypeDefaultDescription
isActivebooleanfalseCurrent page: highlighted, aria-current="page".
tooltipReactNode—Shown to the right while the sidebar is collapsed.
size'default' | 'lg''default'36px row, or a 48px row for a workspace or account.
asChildbooleanfalseRender the child element, e.g. a Next.js Link.

Layout: SidebarHeader, SidebarContent (scrolls), SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuItem, SidebarMenuBadge, SidebarTrigger, SidebarInset. Nested items: SidebarMenuSub with a SidebarMenuSubTrigger and a SidebarMenuSubContent of SidebarMenuSubItem / SidebarMenuSubButton. useSidebar() returns open, collapsed, isMobile and toggle.

Keyboard

KeyAction
Ctrl / ⌘ + BCollapse or expand the sidebar (opens the sheet on mobile).
TabMoves through the rows; closed nested items are skipped.
Enter / SpaceActivates a row or opens a nested group.
EscCloses the mobile sheet.

Accessibility

  • An aside landmark with a label; on mobile a modal sheet with a title.
  • The trigger reports aria-expanded; nested groups use aria-expanded and aria-controls.
  • While collapsed each icon-only row keeps its accessible name (its label is clipped, not removed) and shows a tooltip on hover and keyboard focus.

Motion

  • The width animates on the smooth spring and never on first load; labels are clipped, so nothing reflows while it moves.
  • Nested items open with a height spring; the chevron turns on the snappy spring.
  • Reduced motion keeps the state change and drops the movement.