Skip to content

Navigation

Nav

Main site navigation after the portfolio pattern. Below a container width of 42rem it collapses into a menu.

  • Ready
  • Keyboard tested
  • Screen reader not tested yet

Updated 2026-11-12

Playground

Change the props. The controls come from the documented props.
tsx
<Nav
  label="Playground navigation"
  brand="free•lenz"
  brandHref="#"
  current="#work"
  items={[
    { label: "Work", href: "#work" },
    { label: "About", href: "#about" },
    { label: "Contact", href: "#contact" },
  ]}
/>

States

Every variant in every state, side by side. Hover, pressed and focus are shown statically; the default state is interactive.

Usage

When to use

Use Nav once per page for the main site navigation, at the top.

When not to use

  • For navigation within a section: use SideNav.
  • For subpages of one topic: use TabNav.

How it works

The brand on the left, up to five entries on the right; the current entry is marked with aria-current and an underline. When the container is narrower than 42rem, the entries collapse into a menu behind a toggle that reports its state; Esc closes the menu and returns focus to the toggle.

Content guidelines

Entries are one or two words and match the page titles. Five at most, no dropdowns.

Do and don’t

Do
  • Five entries at most.
  • Name entries by what people find there; put actions such as language or availability in actions.
Don’t
  • No dropdowns in the main navigation.
  • Don't put actions such as “Download CV” among the destinations.

Anatomy

The parts of the component and what each one does, as in the playground above.
  1. brandWordmark linking home.
  2. linkTop-level entry, 14px medium in text.secondary.
  3. indicator2px accent line under the current entry.
  4. menu-toggleMobile only; aria-expanded and aria-controls.

Examples

Type-checked, and the same code goes into the AI manifest. Import: import { Nav } from "@/ds";

Props

Checked against the component's TypeScript type on every build.
Nav props
NameTypeDefaultDescription
label (required)string–aria-label of the landmark, unique per page.
items (required)NavItem[]–Entries with label, href and optional match: a further path whose pages mark the item as current location.
currentstring–Path of the current page (e.g. usePathname()).
brandReactNode–Wordmark on the left.
brandHrefstring"/"Target of the wordmark.
brandLabelstring–Accessible name when brand is not plain text.
actionsReactNode–Extra controls on the right, e.g. the search trigger.
menuLabelstring"Menu"Label of the menu toggle.
defaultOpenbooleanfalseInitial state of the mobile menu.

Tokens used

Derived from the utility classes in the component's source. Copy a class with one click.
Tokens used by Nav
TokenTierValueUtility
button.radiuscomponent9999px
nav.bordercomponentrgba(10,10,11,0.08)
nav.heightcomponent64px
nav.link.fgcomponent#555555
nav.link.fgCurrentcomponent#0A0A0B
nav.link.fgHovercomponent#0A0A0B
nav.link.indicatorcomponent#C6492E
accent.defaultsemantic#C6492E
focussemantic#C6492E
spacing.0semantic0px
spacing.1semantic4px
spacing.12semantic48px
spacing.2semantic8px
spacing.4semantic16px
spacing.6semantic24px
spacing.8semantic32px
surface.pagesemantic#FAFAF7
text.primarysemantic#0A0A0B
type.heading.sizesemanticclamp(24px, 2.5vw, 32px)
type.small.sizesemantic14px
weight.mediumsemantic500
weight.semiboldsemantic600

Accessibility

What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
Testing status by check
CheckHowStatus
axe-core rulesAutomated on every npm run check, at desktop and mobile widthRuns on every build
KeyboardAutomated Playwright test (scripts/keyboard.mjs)Tested
Screen readerManualNot tested yet

Keyboard

Nav keyboard interactions
KeyAction
TabMoves through brand, links and the menu toggle.
EnterFollows a link or opens the mobile menu.
EscCloses the mobile menu and returns focus to the toggle.

Semantics and focus

  • <nav aria-label>; the current page has aria-current="page", the parent section of a subpage aria-current="location".
  • Mobile toggle with aria-expanded and aria-controls.
  • Esc closes the menu and returns focus to the toggle.

Contrast

Nav contrast pairings
PairingRatio (x:1)MinimumStatus
text.primary on surface.page18.924.5Pass
text.secondary on surface.page7.134.5Pass
accent.default on surface.page4.574.5Pass
focus on surface.page4.573.0Pass