Skip to content

Sidebar

App shellsMIT
View in Storybook

A React sidebar that groups navigation, marks active items, and can collapse to a compact rail.

bun add @otfdashkit/ui

Preview

Sidebar

Code

import { AppSidebar, BillingStatus, SidebarResizer } from '@otfdashkit/ui'
import { Home, Settings, Users, BarChart3, FileText, Bell } from 'lucide-react'

export function Example() {
  return (
    <div className="h-screen flex">
      <AppSidebar>
        <AppSidebar.Header>
          <span className="text-sm font-bold text-foreground">Acme Inc</span>
        </AppSidebar.Header>
        <AppSidebar.Nav>
          <AppSidebar.Item icon={<Home />} label="Dashboard" active />
          <AppSidebar.Item icon={<Users />} label="Team" />
          <AppSidebar.Item icon={<BarChart3 />} label="Analytics" />
          <AppSidebar.Item icon={<FileText />} label="Documents" />
          <AppSidebar.Separator label="Settings" />
          <AppSidebar.Item icon={<Settings />} label="Settings" />
          <AppSidebar.Item icon={<Bell />} label="Notifications" badge={<span className="text-xs bg-primary text-primary-foreground rounded-full px-1.5">3</span>} />
        </AppSidebar.Nav>
        <AppSidebar.Footer>
          <BillingStatus plan="Pro" usage="3 of 5 seats" progress={60} onUpgrade={() => {}} />
        </AppSidebar.Footer>
        <SidebarResizer />
      </AppSidebar>
      <main className="flex-1 p-6 text-foreground">
        <h1 className="text-xl font-semibold">Dashboard</h1>
        <p className="text-muted-foreground mt-2">Sidebar with collapse, resize, and billing status.</p>
      </main>
    </div>
  )
}

Free with the SDK. This block ships in @otfdashkit/ui under the MIT license.

Props

Props declared in the Sidebar source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
collapsedbooleanfalse
onCollapse() => void
widthstring'240px'

Questions

How do I use a shadcn sidebar with OTF's React SDK?
Import Sidebar, SidebarHeader, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarItem, SidebarFooter, and SidebarSeparator from @otfdashkit/ui. Compose these slots inside Sidebar; SidebarItem supports a label, optional icon, active state, href, badge, and onClick.
Can the OTF sidebar collapse to a compact rail?
Yes. Control the collapsed prop from React state and update it from the onCollapse callback. When collapsed, labels and badges are hidden while provided icons remain visible.
How do I mark the active page in the sidebar?
Set active on the matching SidebarItem to show the selected state. Pass href to render the item as an anchor; icon and badge are optional.