Sidebar
App navigation that collapses to an icon rail, with tooltips in the rail.
PROGet Sidebar and 168 other Pro components with pro lifetime — Get Pro
- Category
- Navigation & layout
- Access
- ProPro · unlocked
- Source
- 246 lines · one file
- Added
- 19 Oct 2026
When to use it
Use Sidebar for the main navigation of an app or dashboard. It collapses to a rail of icons with tooltips, groups items under labels, and shows counts as badges. Pass render to use your router's Link so navigation stays client-side.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Sidebar for this.
Install it: npx shadcn@latest add @liro/sidebar
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/sidebar.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import * as React from "react";
import { CreditCard, LayoutDashboard, Users } from "lucide-react";
import { Sidebar, SidebarGroup, SidebarItem } from "@/components/ui/sidebar";
const NAV = [
{ href: "/", label: "Overview", icon: <LayoutDashboard /> },
{ href: "/members", label: "Members", icon: <Users /> },
{ href: "/billing", label: "Billing", icon: <CreditCard /> },
];
export function AppSidebar() {
const pathname = usePathname();
const [collapsed, setCollapsed] = React.useState(false);
return (
<Sidebar collapsed={collapsed} onCollapsedChange={setCollapsed}>
<SidebarGroup label="Workspace">
{NAV.map((item) => (
<SidebarItem
key={item.href}
icon={item.icon}
active={pathname === item.href}
render={(props) => <Link {...props} href={item.href} />}
>
{item.label}
</SidebarItem>
))}
</SidebarGroup>
</Sidebar>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
collapsed | boolean | No | – |
onCollapsedChange | (collapsed: boolean) => void | No | – |
header | React.ReactNode | No | – |
footer | React.ReactNode | No | – |
label | string | No | Accessible name for the nav. Default "Main". The sidebar itself is "<label> sidebar". |
width | number | No | Width when expanded, in px. Default 240. |
railWidth | number | No | Width as an icon rail, in px. Default 60. |
flush | boolean | No | The body neither pads nor scrolls: for one child that scrolls itself. |
bodyClassName | string | No | Classes for the body that holds the children. |
Dependencies
npm packages
clsxlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themedrawertooltipAccessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances
Used in screensAll screens
CRM
A sales pipeline: saved views as tabs, an editable company table, a board and a record drawer.
Analytics
A revenue dashboard: four key figures, revenue over time, channels, top products and what moved.
Evals
Decide whether a prompt version ships: a pass or block gate, pass rates, model checks and cases.