Navigation links as a vertical list
Side nav renders navigation trees for drawers and side menus. Every row is a real link built on the tertiary Button, so shape, sizing, and states match the rest of the system, and sections expand with a separate chevron toggle: tapping the label navigates, tapping the chevron expands.
Basic list
Nested sections
Current page
Controlled, one open at a time
Static group
Icons
A long sidebar
Compact rows, titled sections, a badge, and its own scroll: scrollable keeps the scroll inside the list at both ends and brings the current page into view on load. The branch that holds the current page starts open.
Alternatives
- Use Drill menu instead when the menu fills a phone screen and each branch should open as a level of its own.
Props
Read from the same JSDoc that ships in the package's types. A required prop is marked with an asterisk.
| Prop | Type | Default | Description |
|---|---|---|---|
items* | SideNavEntry[] | Navigation tree to render: rows, and at the top level, sections of rows. | |
size | "default" | "compact" | 'default' | Row density. `default` sets every row on the default control height; `compact` sets
every row on the 32px compact control height, for a long sidebar of
pages (a documentation site's hundred entries). |
scrollable | boolean | false | Make the list its own scroll area: it fills the height its parent
gives it, scrolls inside without carrying the page along at its ends,
and brings the current row into view when it first renders. Put it in
a column with a fixed or sticky height. |
currentHref | string | href of the current page — the exactly matching row gets `aria-current="page"` and the active treatment. | |
expandedIds | string[] | Controlled list of expanded item ids. | |
defaultExpandedIds | string[] | Initially expanded item ids (uncontrolled). The branch and the
collapsible section that hold the current page start open as well, so a
reader landing deep in a long tree sees where they are. | |
onExpandedChange | ((expandedIds: string[]) => void) | Fires with the full new list of expanded ids whenever a toggle is pressed, in both controlled and uncontrolled modes. | |
multiple | boolean | false | Allow several branches expanded at once. Default false: expanding one collapses its siblings, never the section or the rows it sits in. |
onNavigate | ((item: SideNavItem, event: MouseEvent<HTMLElement, MouseEvent>) => void) | Fires when any link is clicked, alongside native navigation — e.g. to close the drawer that contains the list. | |
expandLabel | ((label: string) => string) | (label) => `Expand ${label}` | Accessible name of a collapsed row's or section's toggle, given its label. Defaults to "Expand <label>". |
collapseLabel | ((label: string) => string) | (label) => `Collapse ${label}` | Accessible name of an expanded row's or section's toggle, given its label. Defaults to "Collapse <label>". |
linkComponent | LinkComponent | The component its links render with, such as Next.js's `Link`, so they
navigate through the app's router; passed on to each row's Button. Wins over a
LinkProvider's; a plain `<a>` when neither is set. | |
className | string | '' | Additional CSS classes |
Tested keys
An automated test presses every row below, in a left-to-right and a right-to-left layout.
The collapsible section follows the WAI-ARIA disclosure pattern.
| Key | What it does |
|---|---|
Enter | Opens what it controls, and closes it when it is open. |
Space | Does the same as Enter. |
// From the npm package
import { SideNav } from 'rift-ds/components/SideNav/SideNav';
// Or as source you own, via the shadcn CLI
npx shadcn@latest add https://rift-ds.com/r/side-nav.json3.2 kB gzipped, with everything it imports. Peer dependencies are not counted.
For agents: the props, their allowed values and defaults, and the tested keys, as markdown or as a JSON schema.