Navigation Menu
A site-navigation bar where some items reveal a panel of links (Radix Navigation Menu). Plain items are ordinary links; panel items are disclosures.
Import
Section titled “Import”<script> import NavigationMenu from "@invisible-ui/svelte/NavigationMenu.svelte";</script><script setup> import { NavigationMenu } from "@invisible-ui/vue";</script>import { NavigationMenu } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-navigation-menu></ds-navigation-menu>In Elements, assign the items as a property:
<ds-navigation-menu label="Site"></ds-navigation-menu>
<script type="module"> document.querySelector("ds-navigation-menu").items = [ { value: "home", label: "Home", href: "/" }, { value: "products", label: "Products", links: [{ label: "Catalog", href: "/catalog", description: "Every table in one place" }], }, ];</script>In React, value names the open panel, initially or controlled, and
onValueChange reports what the user opens:
<NavigationMenu label="Main" items={[ { value: "products", label: "Products", links: [{ label: "Analytics", href: "/analytics" }] }, { value: "pricing", label: "Pricing", href: "/pricing" }, ]} onValueChange={(value) => track(value)}/>| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Accessible name for the <nav> landmark. |
items * | NavigationMenuItem[] | — | Links ({ value, label, href }) or panels ({ value, label, links }). |
onValueChange | ((value: string | null) => void) | undefined | undefined | Called when the open panel changes. |
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Accessible name for the navigation landmark. |
items * | NavigationMenuItem[] | — | |
onValueChange | (value: string | null) => void | undefined |
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Accessible name for the navigation landmark. |
items * | NavigationMenuItem[] | — | |
value | string | null | null | The open item's value, or null; initial / controlled. |
onValueChange | (value: string | null) => void | — | Called whenever the user opens, switches or closes a panel. |
| Attribute | Reactive | Description |
|---|---|---|
label * | yes | : the landmark name |
value | yes | the open item |
open-delay | — | ms, 150 |
close-delay | — | ms, 150 |
Reactive attributes re-render the element when they change after the first render.
Properties: items, value.
Emits: bubbling value-change with detail.value (null when closed).
Every href is rendered as given: pass only URLs you trust or have
sanitized. See Security.
A panel link is { label, href, description?, current? }, and a plain link
item accepts current? as well. Set current: true on the one link that
leads to the page on screen.
Accessibility
Section titled “Accessibility”- A
<nav>landmark containing links and disclosure buttons (aria-expanded/aria-controls→ a labelled content panel). At most one panel is open. - The pointer resting on a trigger opens its panel while the pointer stays: after a short delay, or at once while another panel is open. Leaving the trigger and the panel closes it after a short delay.
- A click, a tap, Enter or Space keeps the panel open, also one the pointer opened, and a second press closes it. A click has no delay and no time limit. ArrowDown opens the panel, keeps it open and moves focus to its first link. Escape closes it and returns focus to the trigger; an outside press closes it without moving focus. After a panel is closed by a press or Escape, hover opens it again only once the pointer has left the trigger. Positioning (flip/shift) is handled by the adapter.
- Activating a link closes the open panel before the browser follows the link. Focus is not returned to the trigger: the page you open decides where focus goes. Only when focus would be lost (on the page body) and the trigger is still there does focus go back to the trigger.
- The current page: the link marked
currentgetsaria-current="page"and a visible mark that does not rely on colour alone (an underline at the top level, a bar along the start edge in a panel). The trigger whose panel holds it shows the same mark on screen but is never announced as current. - Assistive technology: not tested.
Example
Section titled “Example”<NavigationMenu label="Main" items={[ { value: "products", label: "Products", links: [ { label: "Analytics", href: "/analytics", description: "Understand traffic." }, ] }, { value: "pricing", label: "Pricing", href: "/pricing" }, ]}/>Themeable via --ds-navmenu-*.