Sidebar

A composable, themeable and customizable sidebar component.

Dashboard

Installation

pnpm dlx cubix@latest add sidebar --base radix

Usage

Import
import {
  Sidebar,
  SidebarContent,
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarInset,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarProvider,
  SidebarTrigger,
} from "@/components/cubix/sidebar"
Example
<SidebarProvider>
  <Sidebar>
    <SidebarContent />
  </Sidebar>
  <SidebarInset>
    <SidebarTrigger />
  </SidebarInset>
</SidebarProvider>

Composition

Use the following composition to build a sidebar layout:

Structure
SidebarProvider
├── Sidebar
   ├── SidebarHeader
   ├── SidebarContent
      └── SidebarGroup
          ├── SidebarGroupLabel
          └── SidebarGroupContent
              └── SidebarMenu
                  └── SidebarMenuItem
                      └── SidebarMenuButton
   ├── SidebarFooter
   └── SidebarRail
└── SidebarInset
    └── SidebarTrigger

Side

Use the side prop to place the sidebar on the left or right.

 
<Sidebar side="left" />
<Sidebar side="right" />

Collapsible

Use the collapsible prop to control how the sidebar collapses. offcanvas slides away, icon collapses to icons, and none disables collapsing.

 
<Sidebar collapsible="offcanvas" />
<Sidebar collapsible="icon" />
<Sidebar collapsible="none" />

API Reference

SidebarProvider

PropTypeDefaultDescription
defaultOpenbooleantrueInitial open state when uncontrolled.
openboolean-Controlled open state of the sidebar.
onOpenChange(open: boolean) => void-Called when the open state changes.
classNamestring-Additional Tailwind classes merged with the wrapper styles (last one wins).
childrenReact.ReactNode-Sidebar and inset content.

Sidebar

PropTypeDefaultDescription
side"left" | "right""left"Which side of the layout the sidebar appears on.
variant"sidebar" | "floating" | "inset""sidebar"Visual style of the sidebar panel.
collapsible"offcanvas" | "icon" | "none""offcanvas"How the sidebar collapses on desktop.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
childrenReact.ReactNode-Header, content, footer, and related parts.

SidebarMenuButton

PropTypeDefaultDescription
isActivebooleanfalseMarks the menu button as the active item.
variant"default" | "outline""default"Visual variant of the menu button.
size"default" | "sm" | "lg""default"Size of the menu button.
tooltipstring | TooltipContent props-Tooltip shown when the sidebar is collapsed to icons.
renderReact.ReactElement-Compose the button onto a child element such as an anchor (Base UI).
asChildboolean-Compose the button onto a child element such as an anchor (Radix UI).