codefast/ui

Command Palette

Search for a command to run...

Source
Navigation

Sidebar

Composable application sidebar with collapsible groups, rail, and mobile sheet. Built for app shells.

Examples

Anatomy

How the parts nest — every slot the component exposes, in composition order.

SidebarProvider
├── Sidebar
│ └── SidebarContent
│ └── SidebarGroup
│ └── SidebarMenu
│ └── SidebarMenuItem
│ └── SidebarMenuButton
└── SidebarTrigger

Features

  • Persists the open/collapsed state in a sidebar_state cookie (7-day max-age), so a full page reload keeps the sidebar as the user left it.
  • Automatically switches to a Sheet-based drawer on mobile via useIsMobile() — no separate mobile layout to build.

API reference

Props for each part of the component. All native element props are also forwarded.

SidebarProvider

Wraps the shell; owns collapse state and keyboard shortcut.

defaultOpenboolean

Whether the sidebar starts expanded.

Defaulttrue

openboolean

The controlled open (expanded) state.

onOpenChange(open: boolean) => void

Called when the open state changes.

Sidebar parts

SidebarMenuButtonReactNode

A nav row; compose inside SidebarMenuItem / SidebarGroup.

SidebarTrigger

Toggles the sidebar; place it in your main content.

Accessibility

Built to be keyboard-navigable and screen-reader friendly out of the box.

KeyFunction
⌘/Ctrl+BToggles the sidebar from anywhere in the app.
TabMoves through the menu buttons.
EnterActivates the focused item.
  • Built as a nav landmark; the collapsed rail keeps icons reachable.
  • On mobile it becomes a sheet — ensure the trigger is always reachable.
  • Give icon-only collapsed items accessible names (tooltips or labels).

Guidelines

Conventions that keep usage consistent across an app.

Do

  • Use for app shells with persistent navigation.
  • Group links with labels and keep the list shallow.

Don’t

  • Don’t use a sidebar for a content site with few pages.
  • Don’t hide the toggle — users need a way back.

Explore further

Ready to integrate?

Follow the Getting Started guide to install @codefast/ui, or browse the full component gallery.