Skip to main content

Sidebar

A comprehensive sidebar component system with provider, header, content, menu items, and inset layout. Supports collapsible states, mobile responsiveness, keyboard shortcuts, and multiple variants.

Installation

Loading...

Import

Loading...

Usage

Use SidebarProvider to wrap your application and provide sidebar context. Use Sidebar for the navigation panel and SidebarInset for the main content area. Organize menu items with SidebarGroup and SidebarGroupLabel. Use SidebarMenuSub for nested navigation. The sidebar automatically handles mobile responsiveness, keyboard shortcuts (Cmd/Ctrl + B), and state persistence.

Design Guidelines

Use consistent sidebar structure throughout your application. Group related items with SidebarGroup. Use SidebarGroupLabel for clear section headers. Keep menu item labels concise. Use icons consistently. Choose appropriate variant (sidebar, floating, inset) based on your design. Use collapsible='icon' for space-efficient layouts. Maintain consistent spacing and styling.

Basic Usage

Simple sidebar with header, menu, and content

Loading...

With Groups

Sidebar with grouped menu items

Loading...

With Submenu

Sidebar with nested submenu items

Loading...

Floating Variant

Sidebar with floating variant styling

Loading...

Collapsible Options

Sidebar with different collapsible modes

Loading...

SidebarProvider

Provider component that manages sidebar state and context extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
defaultOpen
booleantrue

Default open state of the sidebar

open
boolean

Controlled open state of the sidebar

onOpenChange
(open: boolean) => void

Callback fired when the open state changes

sidebarWidth
string"20rem"

Width of the sidebar when expanded

sidebarIconWidth
string"3.5rem"

Width of the sidebar when collapsed to icon mode

sidebarKeyboardShortcut
string"b"

Keyboard shortcut key to toggle the sidebar (used with Cmd/Ctrl)

className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

Sidebar

Main sidebar container component extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
side
"left" | "right""left"

Side of the screen where the sidebar is positioned

variant
"sidebar" | "floating" | "inset""sidebar"

Visual variant of the sidebar

collapsible
"offcanvas" | "icon" | "none""icon"

Collapsible behavior of the sidebar

className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarHeader

Header section of the sidebar extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarContent

Main content area of the sidebar extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarGroup

Group container for related menu items extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarGroupLabel

Label for a sidebar group extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarMenu

Menu container for sidebar items This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarMenuItem

Individual menu item container This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarMenuButton

Button component for menu items extends Button. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
isActive
booleanfalse

Whether the menu button is in an active state

tooltip
string | React.ComponentProps<typeof TooltipContent>

Tooltip content to display when sidebar is collapsed

variant
"default" | "ghost" | "outline""default"

Visual variant of the button

buttonSize
"sm" | "default" | "lg""default"

Size of the button

className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarMenuSub

Submenu container This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
open
boolean

Whether the submenu is open

className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarMenuSubItem

Individual submenu item container This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarMenuSubButton

Button component for submenu items extends Link. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
linkSize
"sm" | "md""md"

Size of the link button

isActive
booleanfalse

Whether the submenu button is in an active state

className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarInset

Main content area that sits next to the sidebar extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarRail

Rail component for sidebar interactions This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarTrigger

Button component to toggle the sidebar extends Button. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
icon
IconName"side-panel-left"

Icon to display in the trigger button

label
string"Toggle Sidebar"

Accessible label for the trigger button

className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarFooter

Footer section of the sidebar extends Box. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarSeparator

Separator component for the sidebar extends Separator. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

SidebarInput

Input component styled for sidebar use extends Input. This component supports common style props for spacing, layout, flexbox, grid, and more. Style props export common Tailwind classes as props to help in building consistent UI. See style props documentation for details.

NameTypeDefaultDescription
className
string

Additional CSS classes to apply to the component

asChild
booleanfalse

When true, uses Radix Slot to compose functionality onto the child component instead of rendering a default element. The child component must spread props and forward refs. See Radix UI composition guide for details.

Accessibility

Accessibility features and considerations

Sidebar includes proper ARIA attributes and keyboard navigation. Menu buttons are keyboard accessible. Use isActive prop to indicate the current page. Ensure proper heading hierarchy in sidebar content. Mobile sidebar uses Sheet component with proper focus management.