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
Playground
Change the props. The controls come from the documented props.
<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.
mobile
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
DoThree to five destinations, named by what people find there. Open the menu at narrow widths. Don’tSeven entries, some of them actions: the main navigation stops being a map.
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.
- brandWordmark linking home.
- linkTop-level entry, 14px medium in text.secondary.
- indicator2px accent line under the current entry.
- 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";
Desktop
Props
Checked against the component's TypeScript type on every build.
| Name | Type | Default | Description |
|---|---|---|---|
| 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. |
| current | string | – | Path of the current page (e.g. usePathname()). |
| brand | ReactNode | – | Wordmark on the left. |
| brandHref | string | "/" | Target of the wordmark. |
| brandLabel | string | – | Accessible name when brand is not plain text. |
| actions | ReactNode | – | Extra controls on the right, e.g. the search trigger. |
| menuLabel | string | "Menu" | Label of the menu toggle. |
| defaultOpen | boolean | false | Initial state of the mobile menu. |
Tokens used
Derived from the utility classes in the component's source. Copy a class with one click.
| Token | Tier | Value | Utility |
|---|---|---|---|
| button.radius | component | 9999px | |
| nav.border | component | rgba(10,10,11,0.08) | |
| nav.height | component | 64px | |
| nav.link.fg | component | #555555 | |
| nav.link.fgCurrent | component | #0A0A0B | |
| nav.link.fgHover | component | #0A0A0B | |
| nav.link.indicator | component | #C6492E | |
| accent.default | semantic | #C6492E | |
| focus | semantic | #C6492E | |
| spacing.0 | semantic | 0px | |
| spacing.1 | semantic | 4px | |
| spacing.12 | semantic | 48px | |
| spacing.2 | semantic | 8px | |
| spacing.4 | semantic | 16px | |
| spacing.6 | semantic | 24px | |
| spacing.8 | semantic | 32px | |
| surface.page | semantic | #FAFAF7 | |
| text.primary | semantic | #0A0A0B | |
| type.heading.size | semantic | clamp(24px, 2.5vw, 32px) | |
| type.small.size | semantic | 14px | |
| weight.medium | semantic | 500 | |
| weight.semibold | semantic | 600 |
Accessibility
What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
| Check | How | Status |
|---|---|---|
| axe-core rules | Automated on every npm run check, at desktop and mobile width | Runs on every build |
| Keyboard | Automated Playwright test (scripts/keyboard.mjs) | Tested |
| Screen reader | Manual | Not tested yet |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves through brand, links and the menu toggle. |
| Enter | Follows a link or opens the mobile menu. |
| Esc | Closes 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
| Pairing | Ratio (x:1) | Minimum | Status |
|---|---|---|---|
| text.primary on surface.page | 18.92 | 4.5 | Pass |
| text.secondary on surface.page | 7.13 | 4.5 | Pass |
| accent.default on surface.page | 4.57 | 4.5 | Pass |
| focus on surface.page | 4.57 | 3.0 | Pass |