Components
Sidebar
A collapsible navigation rail for an app's main sections.
pnpm dlx shadcn@latest add @caliper/sidebarWhen to use
Use it for
- Product navigation with five to ten destinations.
- Layouts that need an icon-only collapsed state.
Skip it when
- A marketing site; use a header.
Installation
pnpm dlx shadcn@latest add @caliper/sidebar
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above.
import { FolderOpen, Home, Inbox, Settings } from "lucide-react" import { useState } from "react" import { Sidebar } from "@/components/ui/sidebar" const sidebarPages: Record<string, [string, string]> = { home: ["Home", "4 projects active · 2 need review"], inbox: ["Inbox", "3 unread from Priya Raman and Elias Kim"], files: ["Files", "128 files · 2.4 GB of 10 GB"], settings: ["Settings", "Team plan · 14 seats · renews 1 Nov"], }; export function ProjectSidebar() { const [item, setItem] = useState("home"); const [collapsed, setCollapsed] = useState(false); const [title, detail] = sidebarPages[item]!; return ( <div className="flex w-full max-w-xl overflow-hidden rounded-overlay border border-border bg-background shadow-resting"> <Sidebar label="Halden" items={[ { id: "home", label: "Home", icon: <Home aria-hidden="true" /> }, { id: "inbox", label: "Inbox", icon: <Inbox aria-hidden="true" /> }, { id: "files", label: "Files", icon: <FolderOpen aria-hidden="true" /> }, { id: "settings", label: "Settings", icon: <Settings aria-hidden="true" /> }, ]} value={item} onValueChange={setItem} collapsed={collapsed} onCollapsedChange={setCollapsed} /> <div className="grid min-w-0 flex-1 content-start gap-1 p-6"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{detail}</p> </div> </div> ); }
API reference
Sidebar
component
Accessibility
It is built on native elements and keeps aria-label, aria-pressed, aria-hidden and aria-current in step with state.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.
Need the complete app?
Customers, invoices, team, billing and settings, built as editable React screens. The SaaS app template is $79 once, with lifetime updates. Connect your own backend.
Preview the SaaS app template