Navigation Menu
A collection of expandable navigation panels paired with native destination links.
Navigation Menu combines expandable navigation panels with native destination links inside a navigation landmark. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<shadcn-navigation-menu-root id="shadcn-nav-hero">
<shadcn-navigation-menu-trigger
data-nav-part="trigger"
data-value="getting-started"
>
Getting started ▾
</shadcn-navigation-menu-trigger>
<shadcn-navigation-menu-content
data-nav-part="content"
data-value="getting-started"
>
<div class="grid gap-1 w-[360px] p-1">
<shadcn-navigation-menu-link data-nav-link="intro">
<span class="grid gap-1 text-left">
<span class="block text-sm font-medium leading-none">
Introduction
</span>
<span class="block text-xs opacity-80">
Re-usable components built with Proto UI prototypes.
</span>
</span>
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-link data-nav-link="install">
<span class="grid gap-1 text-left">
<span class="block text-sm font-medium leading-none">
Installation
</span>
<span class="block text-xs opacity-80">
How to install adapters and structure your app.
</span>
</span>
</shadcn-navigation-menu-link>
</div>
</shadcn-navigation-menu-content>
<shadcn-navigation-menu-trigger
data-nav-part="trigger"
data-value="components"
>
Components ▾
</shadcn-navigation-menu-trigger>
<shadcn-navigation-menu-content
data-nav-part="content"
data-value="components"
>
<div class="grid gap-1 sm:grid-cols-2 w-[480px] p-1">
<shadcn-navigation-menu-link data-nav-link="alert-dialog">
Alert Dialog
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-link data-nav-link="tabs">
Tabs
</shadcn-navigation-menu-link>
</div>
</shadcn-navigation-menu-content>
<shadcn-navigation-menu-trigger
data-nav-part="trigger"
data-value="resources"
>
Resources ▾
</shadcn-navigation-menu-trigger>
<shadcn-navigation-menu-content
data-nav-part="content"
data-value="resources"
>
<shadcn-navigation-menu-link data-nav-link="changelog">
Changelog
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-item data-nav-item="search">
Search documentation
</shadcn-navigation-menu-item>
</shadcn-navigation-menu-content>
</shadcn-navigation-menu-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-nav-hero');
setElementProps(root, {
styleProfile: 'rhea',
a11yLabel: 'Main navigation',
});
root.querySelectorAll('[data-nav-part]').forEach((el) => {
setElementProps(el, { value: el.getAttribute('data-value') });
});
setElementProps(root.querySelector('[data-nav-link="intro"]'), {
href: '#introduction',
current: true,
});
setElementProps(root.querySelector('[data-nav-link="install"]'), {
href: '#installation',
});
setElementProps(
root.querySelector('[data-nav-link="alert-dialog"]'),
{ href: '#alert-dialog' }
);
setElementProps(root.querySelector('[data-nav-link="tabs"]'), {
href: '#tabs',
});
setElementProps(
root.querySelector('[data-nav-link="changelog"]'),
{ href: '#changelog' }
);
setElementProps(root.querySelector('[data-nav-item="search"]'), {
value: 'search',
textValue: 'Search documentation',
});
</script>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import the prototypes directly from @proto.ui/prototypes-shadcn/navigation-menu and adapt them for your target runtime:
import { navigationMenuRoot, navigationMenuTrigger, navigationMenuContent, navigationMenuItem, navigationMenuLink,} from '@proto.ui/prototypes-shadcn/navigation-menu';import { ShadcnNavigationMenuRoot, ShadcnNavigationMenuTrigger, ShadcnNavigationMenuContent, ShadcnNavigationMenuItem, ShadcnNavigationMenuLink,} from '../proto-ui/components/react';
export function SiteNav() { return ( <ShadcnNavigationMenuRoot styleProfile="rhea" a11yLabel="Main navigation"> <ShadcnNavigationMenuTrigger value="getting-started"> Getting started </ShadcnNavigationMenuTrigger> <ShadcnNavigationMenuContent value="getting-started" a11yLabel="Getting started"> <ShadcnNavigationMenuLink href="/docs" current> Introduction </ShadcnNavigationMenuLink> <ShadcnNavigationMenuItem value="search" textValue="Search docs"> Search docs </ShadcnNavigationMenuItem> </ShadcnNavigationMenuContent> </ShadcnNavigationMenuRoot> );}Composition
Section titled “Composition”NavigationMenuRoot (navigation)├── NavigationMenuTrigger (button, paired by value)└── NavigationMenuContent (region, paired by value) ├── NavigationMenuLink (native <a>) └── NavigationMenuItem (command action)Native Links & Keyboard
Section titled “Native Links & Keyboard”- Native anchor semantics: URL previews,
Enteractivation, and modifier-key or middle-click tab opening are handled natively by the browser. React, Vue, and Vue 2 render a native<a>root; Web Components keep children inside an owned anchor element so focus, styles, and accessibility stay aligned. - Read-only
navigateevent: After native activation,Linkemits a read-onlynavigateevent with{ href, target, rel, modified }for observation or analytics. - Dismissal policy: Ordinary same-window activations close the open panel unless
closeOnSelect={false}. Modifier clicks, middle-clicks, andtarget="_blank"keep the current page’s panel open. Disabling aLinkremoves its destination and blocks activation. - Keyboard roving: Arrow keys move across top-level triggers,
ArrowDown/ArrowUpopen the panel and focus its first or last entry, andEscapecloses the panel and restores focus to the trigger.
Examples
Section titled “Examples”With Icon
Section titled “With Icon”Combine inline icons with navigation links inside Content for scannable status or view menus.
<shadcn-navigation-menu-root id="shadcn-nav-icons">
<shadcn-navigation-menu-trigger data-value="status">
With Icon ▾
</shadcn-navigation-menu-trigger>
<shadcn-navigation-menu-content data-value="status">
<shadcn-navigation-menu-link data-href="#backlog">
<span aria-hidden="true">○</span>
Backlog
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-link
data-href="#todo"
data-current="true"
>
<span aria-hidden="true">◔</span>
To Do
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-link data-href="#done">
<span aria-hidden="true">●</span>
Done
</shadcn-navigation-menu-link>
</shadcn-navigation-menu-content>
</shadcn-navigation-menu-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-nav-icons');
setElementProps(root, {
styleProfile: 'rhea',
a11yLabel: 'Project status navigation',
});
root.querySelectorAll('[data-value]').forEach((el) => {
setElementProps(el, { value: el.getAttribute('data-value') });
});
root.querySelectorAll('[data-href]').forEach((el) => {
setElementProps(el, {
href: el.getAttribute('data-href'),
current: el.getAttribute('data-current') === 'true',
});
});
</script>Links, Current Page & Disabled
Section titled “Links, Current Page & Disabled”Demonstrates current-page state (current -> aria-current="page"), keeping a panel open (closeOnSelect={false}), opening in a new tab (target="_blank"), and disabled links or triggers.
<shadcn-navigation-menu-root id="shadcn-nav-states">
<shadcn-navigation-menu-trigger id="shadcn-guides-trigger">
Guides ▾
</shadcn-navigation-menu-trigger>
<shadcn-navigation-menu-content id="shadcn-guides-content">
<shadcn-navigation-menu-link id="shadcn-link-current">
Overview (current page)
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-link id="shadcn-link-keep-open">
Stay open on click
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-link id="shadcn-link-blank">
Open in new tab ↗
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-link id="shadcn-link-disabled">
Archived guide (disabled)
</shadcn-navigation-menu-link>
</shadcn-navigation-menu-content>
<shadcn-navigation-menu-trigger id="shadcn-disabled-trigger">
Enterprise (disabled)
</shadcn-navigation-menu-trigger>
</shadcn-navigation-menu-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#shadcn-nav-states'), {
styleProfile: 'rhea',
a11yLabel: 'Documentation link states',
});
setElementProps(
document.querySelector('#shadcn-guides-trigger'),
{ value: 'guides' }
);
setElementProps(
document.querySelector('#shadcn-guides-content'),
{ value: 'guides', a11yLabel: 'Guide links' }
);
setElementProps(document.querySelector('#shadcn-link-current'), {
href: '#overview',
current: true,
});
setElementProps(
document.querySelector('#shadcn-link-keep-open'),
{ href: '#api-reference', closeOnSelect: false }
);
setElementProps(document.querySelector('#shadcn-link-blank'), {
href: '#release-notes',
target: '_blank',
});
setElementProps(document.querySelector('#shadcn-link-disabled'), {
href: '#archived',
disabled: true,
});
setElementProps(
document.querySelector('#shadcn-disabled-trigger'),
{ value: 'billing', disabled: true }
);
</script>Controlled & Events
Section titled “Controlled & Events”Manage the active panel externally with value and valueChange, while observing Item.select and Link.navigate.
<shadcn-navigation-menu-root id="shadcn-nav-controlled">
<shadcn-navigation-menu-trigger data-value="docs">
Docs ▾
</shadcn-navigation-menu-trigger>
<shadcn-navigation-menu-content data-value="docs">
<shadcn-navigation-menu-link id="shadcn-ctrl-intro">
Getting started
</shadcn-navigation-menu-link>
<shadcn-navigation-menu-item id="shadcn-ctrl-copy">
Copy install command
</shadcn-navigation-menu-item>
</shadcn-navigation-menu-content>
</shadcn-navigation-menu-root>
<p id="shadcn-ctrl-status" aria-live="polite">Active panel: none</p>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-nav-controlled');
const status = document.querySelector('#shadcn-ctrl-status');
setElementProps(root, {
styleProfile: 'rhea',
value: '',
a11yLabel: 'Controlled navigation',
});
root.querySelectorAll('[data-value]').forEach((el) => {
setElementProps(el, { value: el.getAttribute('data-value') });
});
setElementProps(document.querySelector('#shadcn-ctrl-intro'), {
href: '#getting-started',
current: true,
});
setElementProps(document.querySelector('#shadcn-ctrl-copy'), {
value: 'copy-install',
textValue: 'Copy install command',
});
root.addEventListener('valueChange', (event) => {
const next = event.detail.value;
setElementProps(root, { styleProfile: 'rhea', value: next });
status.textContent = next
? 'Active panel: ' + next
: 'Active panel: none';
});
</script>NavigationMenuRoot
Section titled “NavigationMenuRoot”| Prop / Expose | Type | Default |
|---|---|---|
value | string | undefined (uncontrolled) |
defaultValue | string | '' |
disabled | boolean | false |
loop | boolean | true |
a11yLabel | string | '' |
styleProfile | ShadcnStyleProfile | 'inherit' |
valueChange (event) | { value: string; reason: string } | — |
requestValue (method) | (value: string, reason?: string) => boolean | — |
close (method) | () => void | — |
NavigationMenuTrigger
Section titled “NavigationMenuTrigger”| Prop | Type | Default |
|---|---|---|
value | string | '' |
disabled | boolean | false |
styleProfile | ShadcnStyleProfile | 'inherit' |
NavigationMenuContent
Section titled “NavigationMenuContent”| Prop | Type | Default |
|---|---|---|
value | string | '' |
sideOffset | number | 4 |
a11yLabel | string | '' |
styleProfile | ShadcnStyleProfile | 'inherit' |
NavigationMenuItem
Section titled “NavigationMenuItem”| Prop / Event | Type | Default |
|---|---|---|
value | string | '' |
textValue | string | '' |
disabled | boolean | false |
closeOnSelect | boolean | true |
styleProfile | ShadcnStyleProfile | 'inherit' |
select (event) | { value: string; menuValue: string } | — |
NavigationMenuLink
Section titled “NavigationMenuLink”| Prop / Event | Type | Default |
|---|---|---|
href | string | '' |
target | '_self' '_blank' | '_self' |
rel | string | '' |
current | boolean | false |
disabled | boolean | false |
closeOnSelect | boolean | true |
styleProfile | ShadcnStyleProfile | 'inherit' |
navigate (event) | { href: string; target: string; rel: string; modified: boolean } | — |
select (event) | { value: string; menuValue: string } | — |