Nav list
A sidebar's list of destinations, with sections, the current page and locked rows that say why.
npx shadcn@latest add @silicon-ui/nav-listInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/nav-listManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/nav-list/nav-list.tsx
- components/silicon-ui/nav-list/nav-list.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/menu-highlight.tsx
- components/silicon-ui/lib/fluid-hover.tsx
- components/silicon-ui/lib/silicon-provider.tsx
- components/silicon-ui/lib/sidebar-rail.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
NavList
| Prop | Type | Default |
|---|---|---|
label*Names the navigation for screen readers, such as "Main" or "Settings". | string | — |
children*NavItem and NavSection elements, in order. | ReactNode | — |
classNamePlacement only (width, margins, grid area); the rows' look comes from the component. | string | — |
refThe `<nav>` element. | Ref<HTMLElement> | — |
onNavigateCalled when any row is chosen (click, Enter or Space; link and action rows), before it navigates or acts. A notification, such as closing a phone sheet: it cannot cancel. Locked rows and modified clicks (a new tab or window) do not call it. | (choice: NavChoice) => void | — |
NavSection
| Prop | Type | Default |
|---|---|---|
label*The section's heading, such as "Workspace". | string | — |
children*The section's NavItem rows, or NavSections nested in it (an index: Components › Actions › Buttons). | ReactNode | — |
iconA 16px icon before the heading. | ReactNode | — |
trailingContent at the heading's end, such as how many rows it holds. | ReactNode | — |
collapsibleMakes the heading a row that opens and closes the section, with a chevron before it. A section holding the current page keeps its heading lit while closed. Rows in a collapsible section are indented under its heading. | boolean | — |
defaultOpenWhether a collapsible section starts open. Defaults to true. | boolean | — |
openWhether a collapsible section is open, to control it (with `onOpenChange`), such as opening every section while a search filters the rows. | boolean | — |
onOpenChangeCalled when a collapsible section's heading opens or closes it. | (open: boolean) => void | — |
NavItem
| Prop | Type | Default |
|---|---|---|
children*The row's label. | ReactNode | — |
iconA 16px icon before the label. | ReactNode | — |
activeThe current page: sets aria-current="page" and the active marker. | boolean | false |
disabledTurns the row off. It stays focusable (aria-disabled) so keyboard users can reach it and hear why. | boolean | false |
reasonWhy the row is off, such as "Pro". Shown as a badge and read as the row's description. Only shown when disabled. | string | — |
trailingContent at the row's end, such as a count or an avatar. Hidden while a reason shows. | ReactNode | — |
onIntentCalled each time the pointer enters the row or it receives focus, before it is chosen: start loading the destination (prefetch). It can fire more than once, so keep it idempotent. Not called while disabled. | () => void | — |
classNamePlacement only; the row's look comes from the component. | string | — |
href | string | — |
onSelect | never | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokensbadge