Nav Sidebar
App navigation beside the page: docked, floating or inset. Collapses to a rail of icons or slides out, can peek open on hover, and becomes an overlay on narrow layouts.
Installation
Usage
import {
NavSidebar,
NavSidebarContent,
NavSidebarGroup,
NavSidebarInset,
NavSidebarItem,
NavSidebarLayout,
NavSidebarTrigger,
} from "@/components/navigation/nav-sidebar"
<NavSidebarLayout className="h-dvh">
<NavSidebar collapse="icons">
<NavSidebarContent>
<NavSidebarGroup>
<NavSidebarItem render={<Link href="/inbox" />} icon={<InboxIcon />} active badge={4}>
Inbox
</NavSidebarItem>
</NavSidebarGroup>
</NavSidebarContent>
</NavSidebar>
<NavSidebarInset>
<header>
<NavSidebarTrigger />
</header>
{children}
</NavSidebarInset>
</NavSidebarLayout>Examples
API Reference
NavSidebarLayout
| Prop | Type | Default |
|---|---|---|
openControlled expanded state. Or defaultOpen with onOpenChange. | boolean | – |
defaultOpenStarting state when uncontrolled. | boolean | true |
onOpenChangeCalled when it expands or collapses. | (open: boolean) => void | – |
shortcutKey that toggles it with ⌘ or Ctrl. | string | false | "b" |
breakpointLayout width in px below which the sidebar becomes an overlay with a scrim. | number | 768 |
NavSidebar
| Prop | Type | Default |
|---|---|---|
side | "left" | "right" | "left" |
variantDocked runs full height on the edge; floating is an inset card; inset puts the page in a card. | "docked" | "floating" | "inset" | "docked" |
collapseCollapsed, it shrinks to a rail of icons, slides fully out, or never collapses. | "icons" | "offcanvas" | "none" | "icons" |
expandOnHoverWith icons: hovering the rail opens it over the page until the pointer leaves. | boolean | false |
surface | "sidebar" | "background" | "glass" | "sidebar" |
widthExpanded width in px. | number | 256 |
railWidthCollapsed width in px, with icons. | number | 56 |
indicatorHow the current page stands out. Fill and bar slide between items. | "fill" | "bar" | "text" | "fill" |
density | "compact" | "comfortable" | "comfortable" |
motion | "spring" | "tween" | "spring" |
NavSidebarItem
| Prop | Type | Default |
|---|---|---|
iconShown alone on the rail. | ReactNode | – |
activeThe current page. | boolean | – |
badgeA count at the end. A dot on the rail. | ReactNode | – |
hrefRenders a plain link. Without it, a button. | string | – |
renderYour router's link, e.g. <Link href=… />. | ReactElement | – |
NavSidebarTrigger
| Prop | Type | Default |
|---|---|---|
onlyWhenHiddenRender only while the sidebar is out of view. Use it in the page when your main trigger is in the sidebar. | boolean | false |