Nav
A vertical list of destinations for a sidebar.
On this page
A nav is a vertical list of destinations for a sidebar or a settings page. Rows are quiet until touched, and the current one rises as a small sheet, the way the current option of a segmented control does. Use .nav on a <nav> and nav-item on each link.
Nav
<div class="tray max-w(240) mx-auto p(8)"> <nav class="nav" aria-label="Workspace"> <a class="nav-item" href="#overview" aria-current="page"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M5 12 12 5l7 7M7 10v9h10v-9" /> </svg>Overview</a> <a class="nav-item" href="#projects"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="4" y="4" width="7" height="7" rx="1.5" /> <rect x="13" y="4" width="7" height="7" rx="1.5" /> <rect x="4" y="13" width="7" height="7" rx="1.5" /> <rect x="13" y="13" width="7" height="7" rx="1.5" /> </svg>Projects <span class="nav-end">12</span> </a> <a class="nav-item" href="#domains"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="12" cy="12" r="9" /> <path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18" /> </svg>Domains</a> <a class="nav-item" aria-disabled="true"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="3" y="6" width="18" height="13" rx="2" /> <path d="M3 10h18" /> </svg>Billing</a> </nav></div>#Labels and counts
nav-label captions a set of rows. nav-end sets a count, a shortcut or a badge at the end of a row, in tabular figures.
Labels and counts
<nav class="nav max-w(240) mx-auto" aria-label="Inbox"> <div class="nav-label">Inbox</div> <a class="nav-item" href="#unread" aria-current="page">Unread <span class="nav-end">24</span> </a> <a class="nav-item" href="#mentions">Mentions <span class="nav-end">3</span> </a> <a class="nav-item" href="#archive">Archive</a> <div class="nav-label">Teams</div> <a class="nav-item" href="#design">Design</a> <a class="nav-item" href="#engineering">Engineering <span class="badge badge-sm nav-end">New</span> </a></nav>#Groups
A group is a native <details> with nav-group. Its <summary> is a row with nav-item and nav-toggle, which adds a chevron; the rows under it go in a nav-sub, set in on a hairline guide. The browser keeps the toggle and the keys, and find-in-page opens a folded group that holds a match. The group opens to its own height where interpolate-size is supported, and at once elsewhere.
Groups
<nav class="nav max-w(240) mx-auto" aria-label="Project"> <a class="nav-item" href="#overview"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M5 12 12 5l7 7M7 10v9h10v-9" /> </svg>Overview</a> <details class="nav-group" open> <summary class="nav-item nav-toggle"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M12 16V4M7 9l5-5 5 5M5 20h14" /> </svg>Deployments</summary> <div class="nav-sub"> <a class="nav-item" href="#production" aria-current="page">Production</a> <a class="nav-item" href="#preview">Preview</a> </div> </details> <details class="nav-group"> <summary class="nav-item nav-toggle"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M4 6h10M18 6h2M4 12h2M10 12h10M4 18h10M18 18h2" /> <circle cx="16" cy="6" r="2" /> <circle cx="8" cy="12" r="2" /> <circle cx="16" cy="18" r="2" /> </svg>Settings</summary> <div class="nav-sub"> <a class="nav-item" href="#general">General</a> <a class="nav-item" href="#environment">Environment</a> </div> </details></nav>#Accessibility
- Wrap the list in a
<nav>with a label, and mark the current page witharia-current="page". - For a link that is not available, use
aria-disabled="true"and remove thehref. - A nav of sibling pages inside a page is tabs; the path above a page is a breadcrumb.
#Classes
| Class | Description |
|---|---|
nav | The list, on a nav with a label |
nav-item | A destination: a link, a button, or the summary of a group. Quiet until touched; the current one rises as a small sheet |
nav-end | A count, a shortcut or a badge at the end of a row, in tabular figures |
nav-label | A quiet caption over a set of rows |
nav-group | A details that folds a set of rows under its summary |
nav-toggle | On the summary of a group: adds a chevron at the end of the row, which turns over while the group is open. With nav-item |
nav-sub | The rows under a group, set in from the icon column on a hairline guide |
#Custom properties
| Property | Default | Description |
|---|---|---|
--nav-item-height | 2rem | Row height; at least 2.75rem on touch screens |
--nav-item-radius | var(--radius-control-sm) | Row corner |