Nav sidebar preview

Nav sidebar

The left-hand navigation of a desktop app: grouped items with icons and badges, a pill that glides to the active page, and a collapse button (or ⌘B) that folds it into an icon rail where every icon shows its label in a tooltip.

  • Group
    Sidebars
  • Origin
    Inspired · Original (this library)
  • License
    MIT
  • Added
    Oct 26
npx shadcn@latest add @deank/nav-sidebar

The registry stays private. Install from the repo with a GitHub token — see the README.

Usage

import { NavSidebar } from "@/registry/components/nav-sidebar/nav-sidebar";

<NavSidebar sections={[/* … */]} value="…" onChange={() => {}} />

Props

PropTypeDefaultDescription
sectionsNavSidebarSection[]
valuestringId of the active item
onChange(id: string) => void
brand?{ mark: ReactNode; name: string }Mark and name at the top. The name hides in the rail.
footer?ReactNode | ((collapsed: boolean) => ReactNode)Pinned to the bottom, such as an account row. Receives whether the sidebar is collapsed.
collapsed?booleanControlled collapsed state
defaultCollapsed?booleanfalse
onCollapsedChange?(collapsed: boolean) => void
collapsible?booleantrueShow the collapse button and listen for ⌘B / Ctrl+B
width?number248Width when open, in px
railWidth?number64Width of the icon rail, in px
label?string"Main"Accessible name for the navigation landmark

When to use

The main navigation of a desktop web app, dashboard or admin tool with roughly 5 to 20 destinations in a few groups, where people want to fold it away to give the content more room.

When not to use

Mobile navigation (tab-bar, or put this inside a sheet); a handful of app-level shortcuts floating over content (floating-dock); switching views inside one page (direction-aware-tabs, segmented-control); deep trees of files or folders (it is one level only).

Related

Tab bar · Floating dock · Command palette · Profile menu