ComponentsSidebar
Sidebar
Organize app navigation in a sidebar that can collapse.
On this page
Use this component from the local workspace package. Follow the setup guide first. A public npm package and registry are not available yet.
View registry filesImport the component into your page or component file.
import {
Sidebar,
SidebarProvider,
SidebarMenuLink,
} from "@dethink/components";Try the examples, then open the code to use them in your app.
Dashboard navigation
A labelled nav landmark with grouped links, current route state, badges, shortcuts, trigger, rail, and content inset.
Collapsed rail
Icon rail mode preserves accessible names while trading visual labels for workspace width.
Show sourceexamples/sidebar/collapsed.tsx
"use client";
import {
Sidebar,
SidebarContent,
SidebarGroup,
SidebarGroupContent,
SidebarGroupLabel,
SidebarInset,
SidebarMenu,
SidebarMenuItem,
SidebarMenuLink,
SidebarProvider,
SidebarRail,
} from "@dethink/components";
import { FileBarChart, FolderKanban, Inbox } from "lucide-react";
const collapsedItems = [
{ href: "/inbox", icon: Inbox, label: "Inbox" },
{ href: "/projects", icon: FolderKanban, label: "Projects" },
{ href: "/reports", icon: FileBarChart, label: "Reports" },
];
export function SidebarCollapsed() {
return (
<SidebarProvider defaultCollapsed motion="subtle">
<div className="border-border bg-background flex h-72 overflow-hidden rounded-lg border">
<Sidebar aria-label="Collapsed navigation" variant="bordered">
<SidebarContent>
<SidebarGroup>
<SidebarGroupLabel>Rail</SidebarGroupLabel>
<SidebarGroupContent>
<SidebarMenu>
{collapsedItems.map((item, index) => {
const Icon = item.icon;
return (
<SidebarMenuItem key={item.href}>
<SidebarMenuLink
current={index === 0}
href={item.href}
icon={<Icon aria-hidden="true" />}
>
{item.label}
</SidebarMenuLink>
</SidebarMenuItem>
);
})}
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
</SidebarContent>
<SidebarRail />
</Sidebar>
<SidebarInset className="text-muted-foreground p-5 text-sm">
Collapsed labels remain in the accessibility tree while visual space
stays compact.
</SidebarInset>
</div>
</SidebarProvider>
);
}Mobile menu
A contained mobile navigation handoff with explicit open and close states for embedded workspace previews.
Examples that combine components for common tasks.
AI workspace navigation
A floating sidebar with nested workflow navigation, live badges, disabled items, motion preset state, and dashboard content.
Sidebar is composable. The provider owns shared state; parts render semantic navigation, controls, drawers, and app-shell companions.
| Prop | What it does | Default |
|---|---|---|
SidebarProvider{ animate, collapsed, defaultCollapsed, onCollapsedChange, mobileOpen, defaultMobileOpen, onMobileOpenChange, side, variant, motion } | Owns desktop collapsed state, mobile drawer state, side placement, visual variant, animation opt-out, and motion preset. | Not set |
Sidebarnav attributes + { side, variant } | The labelled navigation landmark. Side and variant default from the provider but can be overridden. | aria-label="Sidebar" |
SidebarMenuLink{ href, current, active, disabled, external, asChild, icon, description, badge, shortcut, tooltip } | Navigation item rendered as a real link by default, with aria-current and data-state hooks for current route styling. Current items render an animated selection indicator; collapsed items expose a CSS-only tooltip (string labels are used automatically, or pass tooltip), a badge dot, and an initial fallback when no icon is given. | Not set |
SidebarMenuAction{ label, showOnHover } | Icon-sized secondary action. With showOnHover it positions itself at the end of the parent SidebarMenuItem row and reveals on row hover, focus-within, or its own focus. | showOnHover: false |
SidebarSeparatordiv attributes | Decorative token-backed rule for dividing sidebar sections. | Not set |
SidebarGroup{ collapsible, open, defaultOpen, onOpenChange } | Groups dense navigation sections; collapsible groups pair with SidebarGroupTrigger and hide content when closed. | defaultOpen: true |
SidebarTrigger / SidebarRailbutton props | Alternative desktop collapse controls with aria-expanded state. SidebarRail is the standard compact edge tab with a small Motion-powered chevron; it is a binary toggle, not a resize or drag handle. Use SidebarTrigger only when an inline control is intentional, not alongside the rail. | toggle collapse |
SidebarMobile / SidebarMobileTrigger{ label, closeButtonLabel, showCloseButton } / button props | Mobile drawer surface and trigger. The drawer handles Escape, outside click, link activation close, and focus restore. | label: "Sidebar navigation" |
SidebarInset{ as?: "main" | "div" | "section" } | Lightweight content companion for app shells that need Sidebar and main content to share a flex row. | "main" |
animateboolean | Enables the CSS choreography and Motion edge-handle feedback. Set false to resolve every sidebar surface to motion none. | true |
motion"none" | "subtle" | "standard" | "expressive" | Coordinates CSS width, disclosure, drawer, and menu transitions with the Motion-powered edge handle. Reduced-motion preferences disable transform-heavy handle movement. | "standard" |