Navigation menu
Site navigation with links and panels.
In Accessible first
See it live
npm run storybookWhen to use it
In Accessible first: The main sections of a public service site. Not inside the steps of a form.
- Use it when: The main sections of a website, sometimes with a panel of sub-links.
- Not when: App navigation that stays open (sidebar), or actions (dropdown menu).
Instead:
Words
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
See Voice and tone for the whole voice.
Accessibility and keyboard
Test before you ship:
- It is a navigation landmark; the current page is marked. undefined
Use it in code
npx open-ds add navigation-menu
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Navigation menu reads 47 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Navigation menu's tokens to change Navigation menu alone.
Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Shared | ||
| Transition panels duration | component.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration) | duration.moderate:200ms |
| List | ||
| Gap | component.navigation-menu.list.gapspace.gap.tightvar(--navigation-menu-list-gap) | space.12:0.75rem |
| Navigation menu | ||
| Corner | component.navigation-menu.radiusradius.controlvar(--navigation-menu-radius) | radius.6:0.375rem |
| Fill Changes with theme | component.navigation-menu.backgroundcolor.surface.canvasvar(--navigation-menu-background) | Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A |
| Padding, left and right | component.navigation-menu.padding-xspace.inset.containervar(--navigation-menu-padding-x) | space.24:1.5rem |
| Padding, top and bottom | component.navigation-menu.padding-ycomponent-spacing-map.x2var(--navigation-menu-padding-y) | space.8:0.5rem |
| Text size | component.navigation-menu.font-sizetype.body.font-sizevar(--navigation-menu-font-size) | font.size.19:1.1875rem |
| Weight | component.navigation-menu.font-weighttype.label.font-weightvar(--navigation-menu-font-weight) | font.weight.700:700 |
| Background hover Changes with theme on hover | component.navigation-menu.background-hovercolor.surface.sunkenvar(--navigation-menu-background-hover) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Label hover Changes with theme on hover | component.navigation-menu.label-hovercolor.text.primaryvar(--navigation-menu-label-hover) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Background focus Changes with theme on focus | component.navigation-menu.background-focuscolor.surface.sunkenvar(--navigation-menu-background-focus) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Label focus Changes with theme on focus | component.navigation-menu.label-focuscolor.text.primaryvar(--navigation-menu-label-focus) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Disabled opacity disabled when disabled | component.navigation-menu.disabled-opacity-disabledopacity.disabledvar(--navigation-menu-disabled-opacity-disabled) | opacity.50:0.5 |
| Background open Changes with theme when open | component.navigation-menu.background-opencolor.surface.sunkenvar(--navigation-menu-background-open) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Label open Changes with theme when open | component.navigation-menu.label-opencolor.text.primaryvar(--navigation-menu-label-open) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Background open hover Changes with theme when open, on hover | component.navigation-menu.background-open-hovercolor.surface.sunkenvar(--navigation-menu-background-open-hover) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Background open focus Changes with theme when open, on focus | component.navigation-menu.background-open-focuscolor.surface.sunkenvar(--navigation-menu-background-open-focus) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Focus on focus | component.navigation-menu.focusborder-width.focusvar(--navigation-menu-focus) | border-width.3:3px |
| Focus ring focus Changes with theme on focus | component.navigation-menu.focus-ring-focuscolor.border.focusvar(--navigation-menu-focus-ring-focus) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Focus ring offset focus Changes with theme on focus | component.navigation-menu.focus-ring-offset-focuscolor.surface.canvasvar(--navigation-menu-focus-ring-offset-focus) | Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A |
| Speed | component.navigation-menu.durationmotion.duration.feedbackvar(--navigation-menu-duration) | duration.moderate:200ms |
| Background 2 Changes with theme | component.navigation-menu.background-2color.surface.raisedvar(--navigation-menu-background-2) | Lightgray.light.0:#FFFFFFDarkgray.dark.100:#222222 |
| Text Changes with theme | component.navigation-menu.labelcolor.text.primaryvar(--navigation-menu-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Shadow | component.navigation-menu.shadowelevation.cardvar(--navigation-menu-shadow) | shadow.none |
| Background 3 Changes with theme | component.navigation-menu.background-3color.border.defaultvar(--navigation-menu-background-3) | Lightgray.light.200:#D6D6D6Darkgray.dark.100:#222222 |
| Shadow 2 | component.navigation-menu.shadow-2elevation.overlayvar(--navigation-menu-shadow-2) | shadow.none:0px 0px 0px 0px #00000000 |
| Content | ||
| Padding | component.navigation-menu.content.paddingcomponent-spacing-map.x2var(--navigation-menu-content-padding) | space.8:0.5rem |
| Padding right | component.navigation-menu.content.padding-rightcomponent-spacing-map.x3var(--navigation-menu-content-padding-right) | space.20:1.25rem |
| Viewport | ||
| Corner | component.navigation-menu.viewport.radiusradius.controlvar(--navigation-menu-viewport-radius) | radius.6:0.375rem |
| Fill Changes with theme | component.navigation-menu.viewport.backgroundcolor.surface.raisedvar(--navigation-menu-viewport-background) | Lightgray.light.0:#FFFFFFDarkgray.dark.100:#222222 |
| Text Changes with theme | component.navigation-menu.viewport.labelcolor.text.primaryvar(--navigation-menu-viewport-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Shadow | component.navigation-menu.viewport.shadowelevation.cardvar(--navigation-menu-viewport-shadow) | shadow.none |
| Link | ||
| Gap | component.navigation-menu.link.gapspace.gap.tightvar(--navigation-menu-link-gap) | space.12:0.75rem |
| Corner | component.navigation-menu.link.radiusradius.badgevar(--navigation-menu-link-radius) | radius.4:0.25rem |
| Padding | component.navigation-menu.link.paddingcomponent-spacing-map.x2var(--navigation-menu-link-padding) | space.8:0.5rem |
| Text size | component.navigation-menu.link.font-sizetype.body.font-sizevar(--navigation-menu-link-font-size) | font.size.19:1.1875rem |
| Background hover Changes with theme on hover | component.navigation-menu.link.background-hovercolor.surface.sunkenvar(--navigation-menu-link-background-hover) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Label hover Changes with theme on hover | component.navigation-menu.link.label-hovercolor.text.primaryvar(--navigation-menu-link-label-hover) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Background focus Changes with theme on focus | component.navigation-menu.link.background-focuscolor.surface.sunkenvar(--navigation-menu-link-background-focus) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Label focus Changes with theme on focus | component.navigation-menu.link.label-focuscolor.text.primaryvar(--navigation-menu-link-label-focus) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Fill Changes with theme | component.navigation-menu.link.backgroundcolor.surface.sunkenvar(--navigation-menu-link-background) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Focus | component.navigation-menu.link.focusborder-width.focusvar(--navigation-menu-link-focus) | border-width.3:3px |
| Text Changes with theme | component.navigation-menu.link.labelcolor.text.primaryvar(--navigation-menu-link-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Icon size | component.navigation-menu.link.icon-sizesize.iconvar(--navigation-menu-link-icon-size) | size.20:1.25rem |
| Label 2 Changes with theme | component.navigation-menu.link.label-2color.text.mutedvar(--navigation-menu-link-label-2) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| Focus ring focus Changes with theme on focus | component.navigation-menu.link.focus-ring-focuscolor.border.focusvar(--navigation-menu-link-focus-ring-focus) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Focus ring offset focus Changes with theme on focus | component.navigation-menu.link.focus-ring-offset-focuscolor.surface.canvasvar(--navigation-menu-link-focus-ring-offset-focus) | Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightgray.light.200 · #D6D6D6Darkgray.dark.100 · #222222 |
| Corner | radius.badge straight from the system, through --radius-sm | radius.4 · 0.25rem (4px) |