Skip to main content

Installation

Structure

A Sidebar component is composed of the following parts:
  • SidebarProvider - Handles collapsible state
  • Sidebar - The sidebar container
  • SidebarHeader and SidebarFooter - Sticky at the top and bottom
  • SidebarContent - Scrollable content area
  • SidebarGroup - Section within the content
  • SidebarTrigger - Button to toggle the sidebar

Usage

Component API

SidebarProvider

Provides sidebar context and state management.
Props:
  • defaultOpen - Default open state (default: true)
  • open - Controlled open state
  • onOpenChange - Callback when open state changes
Main sidebar container.
Props:
  • side - Which side the sidebar appears on
  • variant - Visual variant of the sidebar
  • collapsible - How the sidebar collapses

useSidebar Hook

Access sidebar state and controls.

SidebarHeader

Sticky header section.

SidebarFooter

Sticky footer section.

SidebarContent

Scrollable content container.

SidebarGroup

Groups related sidebar items.

SidebarMenu

Menu list container.

SidebarMenuItem

Individual menu item.

SidebarMenuButton

Clickable menu button.

SidebarTrigger

Button to toggle sidebar.

Examples

Basic Sidebar

Collapsible to Icons

Right Side

Floating Variant

Inset Variant

Controlled Sidebar

Custom Width

With Collapsible Groups

Theming

Customize sidebar colors with CSS variables:

Keyboard Shortcuts

  • Cmd+B (Mac) or Ctrl+B (Windows) - Toggle sidebar

Accessibility

  • Keyboard navigation support
  • Focus management
  • ARIA labels and roles
  • Screen reader announcements