Navigation Menu
A Duostrap navigation menu pairing classic nav-pills and gradient dropdown panels with native anchor links.
Duostrap Navigation Menu preserves classic .nav-pills and .dropdown-menu pixel dimensions and blue gradient highlights while providing a navigation landmark and native browser anchor links.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<duostrap-navigation-menu-root id="duostrap-nav-hero">
<duostrap-navigation-menu-trigger
data-nav-part="trigger"
data-value="getting-started"
>
Getting started ▾
</duostrap-navigation-menu-trigger>
<duostrap-navigation-menu-content
data-nav-part="content"
data-value="getting-started"
>
<div class="grid gap-1 w-[360px] p-1">
<duostrap-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>
</duostrap-navigation-menu-link>
<duostrap-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>
</duostrap-navigation-menu-link>
</div>
</duostrap-navigation-menu-content>
<duostrap-navigation-menu-trigger
data-nav-part="trigger"
data-value="components"
>
Components ▾
</duostrap-navigation-menu-trigger>
<duostrap-navigation-menu-content
data-nav-part="content"
data-value="components"
>
<div class="grid gap-1 sm:grid-cols-2 w-[480px] p-1">
<duostrap-navigation-menu-link data-nav-link="alert-dialog">
Alert Dialog
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-link data-nav-link="tabs">
Tabs
</duostrap-navigation-menu-link>
</div>
</duostrap-navigation-menu-content>
<duostrap-navigation-menu-trigger
data-nav-part="trigger"
data-value="resources"
>
Resources ▾
</duostrap-navigation-menu-trigger>
<duostrap-navigation-menu-content
data-nav-part="content"
data-value="resources"
>
<duostrap-navigation-menu-link data-nav-link="changelog">
Changelog
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-item data-nav-item="search">
Search documentation
</duostrap-navigation-menu-item>
</duostrap-navigation-menu-content>
</duostrap-navigation-menu-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#duostrap-nav-hero');
setElementProps(root, { 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-duostrap/navigation-menu:
import { navigationMenuRoot, navigationMenuTrigger, navigationMenuContent, navigationMenuItem, navigationMenuLink,} from '@proto.ui/prototypes-duostrap/navigation-menu';import { DuostrapNavigationMenuRoot, DuostrapNavigationMenuTrigger, DuostrapNavigationMenuContent, DuostrapNavigationMenuItem, DuostrapNavigationMenuLink,} from '../proto-ui/components/react';
export function ClassicSiteNav() { return ( <DuostrapNavigationMenuRoot a11yLabel="Main navigation"> <DuostrapNavigationMenuTrigger value="getting-started"> Getting started </DuostrapNavigationMenuTrigger> <DuostrapNavigationMenuContent value="getting-started" a11yLabel="Getting started"> <DuostrapNavigationMenuLink href="/docs" current> Introduction </DuostrapNavigationMenuLink> <DuostrapNavigationMenuItem value="download" textValue="Download CSS"> Download CSS </DuostrapNavigationMenuItem> </DuostrapNavigationMenuContent> </DuostrapNavigationMenuRoot> );}Composition
Section titled “Composition”NavigationMenuRoot (navigation)├── NavigationMenuTrigger (nav-pills toggle, paired by value)└── NavigationMenuContent (dropdown-menu region, paired by value) ├── NavigationMenuLink (native <a>) └── NavigationMenuItem (command action)Native Links & Keyboard
Section titled “Native Links & Keyboard”- Native browser semantics: URL previews,
Enteractivation, and modifier/middle-click tabs are handled natively by the browser. - Navigation observation & dismissal:
Linkemits a read-onlynavigateevent ({ href, target, rel, modified }). Ordinary same-window activations close the panel unlesscloseOnSelect={false}; modified clicks, middle-clicks, and_blanktargets keep the panel open. - Disabled controls: Disabled links clear
hrefand block activation; disabled triggers adopt Bootstrap’s muted#999ink.
Examples
Section titled “Examples”With Icon
Section titled “With Icon”Combine compact icons and labels inside classic dropdown panels.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<duostrap-navigation-menu-root id="duostrap-nav-icons">
<duostrap-navigation-menu-trigger data-value="status">
With Icon ▾
</duostrap-navigation-menu-trigger>
<duostrap-navigation-menu-content data-value="status">
<duostrap-navigation-menu-link data-href="#backlog">
<span aria-hidden="true">○</span>
Backlog
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-link
data-href="#todo"
data-current="true"
>
<span aria-hidden="true">◔</span>
To Do
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-link data-href="#done">
<span aria-hidden="true">●</span>
Done
</duostrap-navigation-menu-link>
</duostrap-navigation-menu-content>
</duostrap-navigation-menu-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#duostrap-nav-icons');
setElementProps(root, { 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 active blue-gradient highlighting (current), persistent panels (closeOnSelect={false}), _blank links, and disabled states.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<duostrap-navigation-menu-root id="duostrap-nav-states">
<duostrap-navigation-menu-trigger id="duostrap-guides-trigger">
Guides ▾
</duostrap-navigation-menu-trigger>
<duostrap-navigation-menu-content id="duostrap-guides-content">
<duostrap-navigation-menu-link id="duostrap-link-current">
Overview (current page)
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-link id="duostrap-link-keep-open">
Stay open on click
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-link id="duostrap-link-blank">
Open in new tab ↗
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-link id="duostrap-link-disabled">
Archived guide (disabled)
</duostrap-navigation-menu-link>
</duostrap-navigation-menu-content>
<duostrap-navigation-menu-trigger id="duostrap-disabled-trigger">
Enterprise (disabled)
</duostrap-navigation-menu-trigger>
</duostrap-navigation-menu-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#duostrap-nav-states'), {
a11yLabel: 'Documentation link states',
});
setElementProps(
document.querySelector('#duostrap-guides-trigger'),
{ value: 'guides' }
);
setElementProps(
document.querySelector('#duostrap-guides-content'),
{ value: 'guides', a11yLabel: 'Guide links' }
);
setElementProps(
document.querySelector('#duostrap-link-current'),
{ href: '#overview', current: true }
);
setElementProps(
document.querySelector('#duostrap-link-keep-open'),
{ href: '#api-reference', closeOnSelect: false }
);
setElementProps(document.querySelector('#duostrap-link-blank'), {
href: '#release-notes',
target: '_blank',
});
setElementProps(
document.querySelector('#duostrap-link-disabled'),
{ href: '#archived', disabled: true }
);
setElementProps(
document.querySelector('#duostrap-disabled-trigger'),
{ value: 'billing', disabled: true }
);
</script>Controlled & Events
Section titled “Controlled & Events”Manage the active panel externally via value and valueChange, while observing select and navigate.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<duostrap-navigation-menu-root id="duostrap-nav-controlled">
<duostrap-navigation-menu-trigger data-value="docs">
Docs ▾
</duostrap-navigation-menu-trigger>
<duostrap-navigation-menu-content data-value="docs">
<duostrap-navigation-menu-link id="duostrap-ctrl-intro">
Getting started
</duostrap-navigation-menu-link>
<duostrap-navigation-menu-item id="duostrap-ctrl-copy">
Copy install command
</duostrap-navigation-menu-item>
</duostrap-navigation-menu-content>
</duostrap-navigation-menu-root>
<p id="duostrap-ctrl-status" aria-live="polite">
Active panel: none
</p>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#duostrap-nav-controlled');
const status = document.querySelector('#duostrap-ctrl-status');
setElementProps(root, {
value: '',
a11yLabel: 'Controlled navigation',
});
root.querySelectorAll('[data-value]').forEach((el) => {
setElementProps(el, { value: el.getAttribute('data-value') });
});
setElementProps(document.querySelector('#duostrap-ctrl-intro'), {
href: '#getting-started',
current: true,
});
setElementProps(document.querySelector('#duostrap-ctrl-copy'), {
value: 'copy-install',
textValue: 'Copy install command',
});
root.addEventListener('valueChange', (event) => {
const next = event.detail.value;
setElementProps(root, { 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 | '' |
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 |
NavigationMenuContent
Section titled “NavigationMenuContent”| Prop | Type | Default |
|---|---|---|
value | string | '' |
sideOffset | number | 2 |
a11yLabel | string | '' |
NavigationMenuItem
Section titled “NavigationMenuItem”| Prop / Event | Type | Default |
|---|---|---|
value | string | '' |
textValue | string | '' |
disabled | boolean | false |
closeOnSelect | boolean | true |
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 |
navigate (event) | { href: string; target: string; rel: string; modified: boolean } | — |
select (event) | { value: string; menuValue: string } | — |