Components / navigation
Nav
Where the reader can go: a landmark of links, in a row or a column.
Summary
Where the reader can go: a landmark of links, in a row or a column.
| APG pattern | none |
| Built on | native elements |
| Status | self-tested |
| Since | 0.8.0 |
<Nav label="Command Center" items={[
{ label: 'Overview', href: '/app', current: true },
{ label: 'Items', href: '/app/items', count: 42 },
{ label: 'Docs', href: '/app/docs' }
]} />
<Nav label="Docs" orientation="vertical" items={[
{ label: 'Start here', href: '/docs' },
{ label: 'Standards', items: [{ label: 'Process', href: '/docs/process', current: true }, { label: 'Board', href: '/docs/board' }] }
]} />
A row across an app's top, a column down its side, a rail at its edge, or a tree of pages. One component: the items are the same links in every form.
Anatomy
A <nav data-se="nav"> named by label, holding a list of items. Every item is a real <a> that carries the button anatomy — data-se="button" with the neutral, transparent, small shape — so it takes Button's radius, press and ring and reimplements none of them; it marks the current page with aria-current="page". An item holds its words in label, with an icon before them and a count after. In the vertical form an item may be a group: a native <details> whose summary is the trigger, with an indicator, around a nested list of real links.
| Part | Element | Required |
|---|---|---|
count | <span> | no |
group | <details> | yes |
icon | <span> | no |
indicator | <svg> | yes |
item | <as> | yes |
label | <span> | yes |
list | <ul> | yes |
spinner | the caller's | the caller's |
trigger | <summary> | yes |
<nav data-se="nav" aria-label="Command Center">
<ul data-part="list">
<li><a data-se="button" data-se-text="ui" data-part="item" data-intent="neutral" data-emphasis="transparent" data-size="sm" href="/app" aria-current="page"><span data-part="label">Overview</span></a></li>
<li><a data-se="button" data-se-text="ui" data-part="item" data-intent="neutral" data-emphasis="transparent" data-size="sm" href="/app/items"><span data-part="label">Items</span><span data-part="count">42</span></a></li>
</ul>
</nav>
<nav data-se="nav" data-orientation="vertical" aria-label="Docs">
<ul data-part="list">
<li><details data-part="group" open>
<summary data-part="trigger" data-se-text="ui"><span data-part="label">Standards</span><svg data-part="indicator" aria-hidden="true">…</svg></summary>
<ul data-part="list"><li><a data-se="button" … data-part="item" href="/docs/process" aria-current="page">…</a></li></ul>
</details></li>
</ul>
</nav>
The item carries two anatomies at once, as Carousel's dots do: data-se="button" for what it looks and feels like, data-part="item" for what it is to the nav. The nav's own rules are written against the pair.
Properties
| Property | Values | Default | What it does |
|---|---|---|---|
label | string | required | Names the landmark: Site, Command Center, Docs. A page with two navs needs two names. |
items | NavItem[] | required | The places, in order. A group is an item with items, in the vertical form. |
orientation | horizontal · vertical | horizontal | A row or a column. horizontal writes nothing; vertical writes data-orientation. rail is always a column. |
kind | inline · joined · rail | inline | How the items are drawn. inline, the default, is a row or column of quiet buttons with a gap. joined joins them edge to edge, the way ButtonGroup joins buttons — a segmented bar. rail is a narrow column with each icon above its label, for an app's edge. |
linkAs | React.ElementType | none | A link component rendered for every item in place of the plain <a> — a router's, such as next/link — so a click routes instead of loading a document. It receives href, the button anatomy's data attributes, aria-current and the children unchanged, and must render an <a> with an href. The same prop on Link, Breadcrumb and Pagination. |
States
| State | Expressed as | |
|---|---|---|
| Pressed | :active | |
| Disabled | :disabled | |
| Focused | :focus-visible | |
| Hover | :hover | |
| Current | aria-current |
The current page is the one state the nav writes, and it is aria-current, never a class: the look hangs off the attribute, so what a reader is told and what they see cannot disagree. A group's open or closed state is the platform's [open] on <details>.
Behavior
None of its own. A link navigates; a group's summary opens and closes it, from the platform. The nav does not know which page is current — the caller says, because only the router knows.
Nothing collapses into a More menu. A row that does not fit wraps. Folding the overflow into a menu needs measurement, and measurement needs a script and a resize observer; it is a pattern on top of this component, not in it, and is not written yet.
Accessibility
A landmark, named. <nav> is the navigation landmark, and label is its accessible name — a page with two navs needs two names, or a screen reader's landmark list reads navigation, navigation.
Links, not buttons. Every item is an <a href>: middle-click, cmd-click and copy-address keep working, and a screen reader's links list holds every place the reader can go. Shaping it like a button changes nothing about what it is.
The current page says so. aria-current="page" on the link, which is also the only thing the current look hangs off.
A group is a disclosure the platform runs. <details> and <summary> give the trigger its role, its aria-expanded and its keys; the links inside are in the tab order while the group is open and out of it while closed. A closed group hides where the reader can go, which is why groups start open.
The count is text, read after the label: Items, 42. It carries no live region.
Keyboard
| Key | Result |
|---|---|
Tab | Moves between items; each link and each group summary is a tab stop, from the platform |
Enter, Space on a summary | Opens or closes the group, from the platform |
No arrow keys. A nav is links, not a menubar; arrows would promise a composite the markup does not have.
Roles, states and properties
| Attribute | Set by |
|---|---|
aria-current | always page, set at render |
aria-hidden | always true |
aria-label | set at render |
Focus
Each item is a normal tab stop and draws Button's ring. Nothing moves focus.
Screen reader
Not recorded as verified. Stage 4 of the readiness ladder — driving each component with VoiceOver and NVDA — is unstarted across the package, and no component should claim otherwise until docs/journal/ records the session that did it.
Contrast and target size
npm run check:contrast audits every color pair this component uses across all four skins, light and dark, and fails the build on a shortfall. Two waivers are on the record in docs/audit/DEFERRED.md.
It takes the touch floor under (pointer: coarse) — the visual size is unchanged on a desktop pointer.
Tested
test/apg/app-shell.test.jsxtest/apg/batch-a.test.jsxtest/apg/link-as.test.jsxtest/apg/nav.test.jsxtest/apg/partials-sweep.test.jsxtest/browser/layers.spec.mjstest/browser/nav.spec.mjstest/browser/upstream-natives.spec.mjs
Known gaps
_No upstream requirement is recorded as not applicable._
Appearance
The items are Button's neutral, transparent, small shape, so the row reads as quiet controls, and the current page takes the soft accent fill with the text color — Pagination's current look, on the same attribute. Three kinds:
inline— the items in a row or a column with a space step between them; a column's items fill its width and start-align their words.joined— the items joined edge to edge, the way ButtonGroup joins buttons: each takes the outline emphasis, the seams overlap by one border, only the outer corners are round. A segmented bar.rail— a narrow column, each icon above its label at the smallest size, for an app's edge.
A group's summary takes the same shape as an item, with the indicator turning when the group is open; a group's links are indented by one step.
| Token | Used for |
|---|---|
--se-accent | intent |
--se-accent-soft | background |
--se-bg | background, border-color |
--se-border | border-color |
--se-border-width | border, border-width, margin-inline-start |
--se-control-h | block-size, inline-size |
--se-control-h-lg | block-size, inline-size, min-block-size |
--se-control-h-sm | block-size, inline-size, min-block-size |
--se-duration-fast | transition |
--se-duration-instant | transition |
--se-duration-slow | animation |
--se-ease-standard | transition |
--se-focus-color | outline |
--se-focus-offset | outline-offset |
--se-focus-width | outline |
--se-font-code | font-family |
--se-icon-md | block-size, font-size, inline-size |
--se-icon-sm | block-size, font-size, inline-size |
--se-layer-raised | z-index |
--se-mix-down | background, border-color |
--se-mix-hover | background, border-color |
--se-mix-line | border-color |
--se-mix-press | background |
--se-mix-shade | background, border-color |
--se-mix-soft | background |
--se-negative | intent |
--se-positive | intent |
--se-radius-button | border-radius |
--se-radius-pill | border-radius |
--se-scale-press | scale |
--se-space-1 | gap |
--se-space-2 | gap, padding-block, padding-inline |
--se-space-3 | padding-inline |
--se-space-4 | padding-inline, padding-inline-start |
--se-space-5 | padding-inline |
--se-surface-sunk | background |
--se-target-min | block-size, inline-size |
--se-text | border-color, color, intent |
--se-text-disabled | color |
--se-text-md | font-size |
--se-text-muted | color |
--se-text-on-intent | color |
--se-text-sm | font-size |
--se-text-xs | font-size |
Motion
The group's indicator turns over --se-duration-fast. A group opens at once — <details> has no height to animate to without a script, and a nav should not wait on one.
Content
An item names a place, as a noun. Projects, Open items, Settings. Not a verb: a nav is where you can go, not what you can do.
A count is the number alone. The label says what is counted.
A group names the section its links belong to. Standards, Reference. Two levels at most: a tree deeper than that is a Tree.
Usage
Routing is the app's; pass its link. linkAs={NextLink} renders every item through the router's component, with href, the button anatomy's attributes, aria-current and the children unchanged — the current look and the shape stay. The group's summary is not a link and is not routed. The same prop on Link, Breadcrumb and Pagination.
One nav per region, each named. The app's bar is one, named for the app; a docs tree is another, named Docs. Two unnamed navs on a page is the one accessibility fault this component cannot prevent.
joined for a few peers at the top of a page; inline for a bar or a column; rail for the edge of an app whose main surface wants every pixel. The builder's bar and hosting-event's AppNav are inline; the docs tree is vertical with groups.
Not a Tabs. Tabs switch panels on one page and carry a keyboard contract for it; a nav changes the page. If the address bar does not change, it is not navigation.
When not to use it. For the page's own sections — a table of contents — the type roles and a Prose column. For a trail back to where the reader came from, Breadcrumb. For a tree with more than two levels, Tree.
Notes
One component for the bar, the column, the rail and the tree (Wave 4, N1). The review found a nav built by hand in every app — the builder's .cc-nav, hosting-event's AppNav — and a docs tree built by hand in the site. They are the same links in four shapes, so they are one anatomy with orientation and kind.
The item carries the button anatomy rather than restating it. Carousel's dots set the precedent in 0.6: an item that is a button is one, and takes the radius, the press and the ring from the one place they are written.
Groups are <details>, not a Collapsible. The platform's disclosure needs no script, keeps the links real, and gives the summary its role and keys. The cost is no height animation, which a nav does not want.
Collapsing into a More menu is not built. It needs measurement, and the review's "optionally" is honored by leaving it to a pattern on top — written when an app needs it.