Site navigation
The main links of a site in a <nav> landmark, with the current page marked.
Live example
Vertical (sidebar)
<nav aria-label="Sidebar example" data-nav="vertical">
<ul>
<li><a href="#vertical-title">Overview</a></li>
<li>
<details open>
<summary>Projects</summary>
<ul>
<li><a href="#vertical-title" aria-current="page">Active</a></li>
<li><a href="#vertical-title">Archived</a></li>
</ul>
</details>
</li>
<li>
<details>
<summary>Settings</summary>
<ul>
<li><a href="#vertical-title">Profile</a></li>
<li><a href="#vertical-title">Billing</a></li>
</ul>
</details>
</li>
</ul>
</nav>
Horizontal (top bar)
<nav aria-label="Top bar example" data-nav="horizontal">
<ul>
<li><a href="#horizontal-title" aria-current="page">Home</a></li>
<li>
<details name="top-bar">
<summary>Products</summary>
<ul>
<li><a href="#horizontal-title">Design system</a></li>
<li><a href="#horizontal-title">Icons</a></li>
</ul>
</details>
</li>
<li>
<details name="top-bar">
<summary>Company</summary>
<ul>
<li><a href="#horizontal-title">About</a></li>
<li><a href="#horizontal-title">Careers</a></li>
</ul>
</details>
</li>
<li><a href="#horizontal-title">Contact</a></li>
<li><a href="#horizontal-title" data-button="primary small">Sign up</a></li>
</ul>
</nav>
Attributes
| Attribute or value | Where | Effect |
|---|---|---|
data-nav="vertical | horizontal" | <nav> (empty means vertical) | |
aria-current="page" | the current link (native ARIA) | |
aria-current="true" | a top-level horizontal link to the current section | marked like "page" |
<details> / <summary> | inside an <li> for a collapsible group; open to expand it on load, name for one-at-a-time |
Elevation
Horizontal dropdowns use --dui-elevation-popover and its surface, like a popover. They open at once: native details has no open transition.
Keyboard
| Key | Action |
|---|---|
| Tab | moves to the next link or group summary / Shift+Tab: previous |
| Enter / Space | on a summary, opens or closes the group |
| Enter | on a link, follows it |
Accessibility
- Native
<details>in place of the APG disclosure navigation, not an ARIA menu. aria-current="page"is shown with a bar, a tint and bold text (WCAG 1.4.1).- Give each
<nav>a distinctaria-labelwhen there are several. - Groups do not close on Esc. Enter on the summary does.
Specifications
- HTML
<nav>element - APG Landmark regions
- APG Disclosure navigation example
- MDN
aria-current - MDN
nav - WCAG F73
- APG treeview
- WHATWG the details element
- WCAG Non text contrast
See also
- Organisms
- Source:
css/components/molecules/nav.css,examples/molecules/nav.html - Demos: Dashboard view (Plain HTML, React, Angular, Astro, Vue, Svelte); Account settings view (Plain HTML, React, Angular, Astro, Vue, Svelte); Orders view (Plain HTML, React, Angular, Astro, Vue, Svelte)
How other systems do it
For comparison only; these are not the standard this system follows.
- Apple Human Interface Guidelines: No equivalent
- Material Design 3: No equivalent
- Vercel Geist: No equivalent