Sidebar

A context-driven collapsible sidebar with icon-only collapsed mode. Uses SidebarProvider for state management so any descendant can trigger open/close.

  • Collapsible to 64px icon-only mode
  • Full 240px open mode with labels
  • Context-based state via SidebarProvider
  • Flexible menu, group, and footer slots
Main content

Click the trigger to collapse the sidebar.

import { Sidebar }from "@aetherstack/ui"

sidebar.tsx
"use client"

import {
  SidebarProvider,
  Sidebar,
  SidebarContent,
  SidebarHeader,
  SidebarMenu,
  SidebarMenuItem,
  SidebarMenuButton,
  SidebarTrigger,
} from "@/components/ui/sidebar"
import { LayoutDashboard, Users, Settings } from "lucide-react"

export function SidebarDemo() {
  return (
    <SidebarProvider>
      <div className="flex h-screen">
        <Sidebar>
          <SidebarHeader>
            <span className="font-semibold">My App</span>
          </SidebarHeader>
          <SidebarContent>
            <SidebarMenu>
              <SidebarMenuItem>
                <SidebarMenuButton>
                  <LayoutDashboard className="h-4 w-4" />
                  <span>Dashboard</span>
                </SidebarMenuButton>
              </SidebarMenuItem>
              <SidebarMenuItem>
                <SidebarMenuButton>
                  <Users className="h-4 w-4" />
                  <span>Users</span>
                </SidebarMenuButton>
              </SidebarMenuItem>
              <SidebarMenuItem>
                <SidebarMenuButton>
                  <Settings className="h-4 w-4" />
                  <span>Settings</span>
                </SidebarMenuButton>
              </SidebarMenuItem>
            </SidebarMenu>
          </SidebarContent>
        </Sidebar>
        <main className="flex-1 p-6">
          <SidebarTrigger />
        </main>
      </div>
    </SidebarProvider>
  )
}

Usage

With group labels

Use SidebarGroup with SidebarGroupLabel to organize menu sections.

Props

PropTypeDefaultDescription

SidebarProvider

PropTypeDefaultDescription
defaultOpenbooleantrueInitial open state (uncontrolled).
openbooleanControlled open state.
onOpenChange(open: boolean) => voidCallback fired when the sidebar open state changes.

SidebarMenuButton

PropTypeDefaultDescription
isActivebooleanfalseHighlights the button as the currently active route.
asChildbooleanRender as a child component (e.g. a Next.js Link).

useSidebar

PropTypeDefaultDescription
openbooleanCurrent open state of the sidebar.
setOpen(open: boolean) => voidProgrammatically set the sidebar open state.
toggle() => voidToggle the sidebar between open and collapsed.

* Required props

Accessibility

  • SidebarTrigger renders as a Button with an aria-label describing the open/close action.
  • When collapsed to icon-only mode, visible text labels are hidden but remain in the DOM for screen readers.
  • Use SidebarMenuButton with asChild and a Next.js Link for proper keyboard and screen reader navigation.
  • Ensure SidebarMenuButton isActive is set on the current route for aria-current support.