Sidebar
A composable application sidebar with an icon rail, a mobile drawer, a gliding active indicator, and a keyboard shortcut.
Customize
Installation
npx shadcn@latest add @kinetic/sidebarUsage
Wrap the layout in SidebarProvider, put navigation in Sidebar, and the page in SidebarInset.
import { HomeIcon } from "@heroicons/react/24/outline";
import {
Sidebar,
SidebarContent,
SidebarGroup,
SidebarGroupContent,
SidebarGroupLabel,
SidebarInset,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
SidebarProvider,
SidebarTrigger,
} from "@/components/kinetic/ui/sidebar";
interface AppShellProps {
readonly children: React.ReactNode;
}
export function AppShell({ children }: AppShellProps) {
return (
<SidebarProvider>
<Sidebar>
<SidebarContent>
<SidebarGroup>
<SidebarGroupLabel>Workspace</SidebarGroupLabel>
<SidebarGroupContent>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton isActive tooltip="Home">
<HomeIcon />
<span>Home</span>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
</SidebarContent>
</Sidebar>
<SidebarInset>
<SidebarTrigger />
{children}
</SidebarInset>
</SidebarProvider>
);
}Collapsible
Set collapsible on Sidebar: icon shrinks to an icon rail, offcanvas slides it away, none keeps it open. Add SidebarRail for a thin edge that toggles it on click.
<Sidebar collapsible="offcanvas">...</Sidebar>Variant and side
variant switches between sidebar, floating and inset. side docks it left or right.
<Sidebar variant="floating" side="right">...</Sidebar>State
Control the desktop state with open and onOpenChange on the provider, or read it anywhere with useSidebar(). Cmd or Ctrl + B toggles the sidebar.
const { state, toggleSidebar } = useSidebar();Mobile
Below 768 px the sidebar opens as a drawer with a blurred backdrop (backdropBlurPx). Set contained to keep the layout and drawer inside a container, which is useful for previews.
<SidebarProvider contained className="h-80">...</SidebarProvider>Submenus
Nest SidebarMenuSub with SidebarMenuSubItem and SidebarMenuSubButton. Its open prop expands the rows with a spring and a staggered reveal.
<SidebarMenuSub open={expanded}>
<SidebarMenuSubItem>
<SidebarMenuSubButton href="/settings/profile">Profile</SidebarMenuSubButton>
</SidebarMenuSubItem>
</SidebarMenuSub>Motion preferences
Use speed and blurPx on the provider to tune the collapse and the label reveal. Reduced motion switches states instantly.
API Reference
SidebarProvider / useSidebar
Zero-dependency state provider managing desktop spring width, mobile drawer state, backdrop blur, contained preview mode, and Cmd/Ctrl+B shortcut.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultOpen / open / onOpenChange | boolean / (open: boolean) => void | true | Controlled or uncontrolled desktop expanded state. |
speed / blurPx / backdropBlurPx | number | 1 / 4 / 4 | Spring speed multiplier (0.25-4), staggered label/sub-nav reveal blur (0-12 px), and mobile drawer backdrop blur (0-20 px). |
contained / isMobile | boolean | false / auto | Confines the sidebar layout and mobile drawer inside its container; optional isMobile override. |
Sidebar
Responsive panel with RAF spring width collapse, floating/inset surfaces, and animated mobile drawer.
| Prop | Type | Default | Description |
|---|---|---|---|
collapsible | "icon" | "offcanvas" | "none" | "icon" | Collapses to an icon rail, slides completely offcanvas, or stays permanently open. |
variant | "sidebar" | "floating" | "inset" | "sidebar" | Selects standard docked rail, elevated floating card, or inset shell frame. |
side | "left" | "right" | "left" | Docks the sidebar to the left or right edge. |
SidebarMenu / SidebarMenuButton / SidebarMenuBadge / SidebarMenuAction / SidebarMenuSub / SidebarGroupAction / SidebarInput / SidebarMenuSkeleton / SidebarTrigger / SidebarRail / SidebarInset
Menu list with accent-tinted spring-gliding active pill, collapsed hover tooltip, badges, collapsible spring-height submenus, group actions, filter input, deterministic skeletons, edge resize rail, and main inset region.
| Prop | Type | Default | Description |
|---|---|---|---|
isActive / tooltip / variant / size (SidebarMenuButton) | boolean / string / "default" | "outline" / "default" | "sm" | "lg" | false / undefined / "default" / "default" | Targets the gliding active indicator and displays a tooltip when collapsed to icon mode. |
open / blurPx / speed (SidebarMenuSub) | boolean / number / number | true / inherited / inherited | Toggles interruptible RAF spring height expansion and staggered blur-fade reveal for nested submenu rows. |