Navigation Menu
A site's top-level destinations in a bar, with panels that grow out of it for the destinations that hold more.
'use client';
import { CheckIcon, CoinsIcon, ShareIcon, TerminalIcon } from 'lucide-react';
import { useState } from 'react';
import { Badge } from '@/components/panelui/badge';
import { NavigationMenu } from '@/components/panelui/navigation-menu';
const COMMAND = 'npx panelui-cli init';
export default function NavigationMenuOverview() {
const [copied, setCopied] = useState(false);
const [theme, setTheme] = useState('system');
const [motion, setMotion] = useState('full');
const copy = () => {
void navigator.clipboard?.writeText(COMMAND);
setCopied(true);
window.setTimeout(() => setCopied(false), 1600);
};
return (
<NavigationMenu aria-label="Main">
<NavigationMenu.Brand
href="#"
aria-label="Home"
icon={<img src="https://avatars.githubusercontent.com/u/127331761?v=4" alt="" />}
/>
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" active>
Docs
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Components</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Blocks</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item value="more">
<NavigationMenu.Trigger>v0.18</NavigationMenu.Trigger>
<NavigationMenu.Content className="w-[25rem]">
<NavigationMenu.Profile
description="Maintainer · PanelUI"
status={
<Badge variant="success" dot>
Taking contributions
</Badge>
}
>
Khalid Abdi
</NavigationMenu.Profile>
<NavigationMenu.Card href="#" icon={<TerminalIcon />} eyebrow="Start here">
Install PanelUI
</NavigationMenu.Card>
<NavigationMenu.Card href="#" icon={<CoinsIcon />} eyebrow="New in 0.18">
Currency Input
</NavigationMenu.Card>
<NavigationMenu.Value
actions={
<>
<NavigationMenu.Pill onClick={copy} icon={copied ? <CheckIcon /> : undefined}>
{copied ? 'Copied' : 'Copy'}
</NavigationMenu.Pill>
<NavigationMenu.Pill icon={<ShareIcon />} aria-label="Share" />
</>
}
>
<code className="font-mono text-sm">{COMMAND}</code>
</NavigationMenu.Value>
<NavigationMenu.Pills>
<NavigationMenu.Pill href="https://github.com/panel-ui/PanelUI" external>
GitHub
</NavigationMenu.Pill>
<NavigationMenu.Pill href="https://www.npmjs.com/package/panelui-web" external>
npm
</NavigationMenu.Pill>
<NavigationMenu.Pill href="#" external>
Changelog
</NavigationMenu.Pill>
</NavigationMenu.Pills>
<NavigationMenu.Separator />
<NavigationMenu.Setting label="Theme">
<NavigationMenu.Options aria-label="Theme" value={theme} onValueChange={(next) => setTheme(String(next))}>
<NavigationMenu.Option value="system">System</NavigationMenu.Option>
<NavigationMenu.Option value="light">Light</NavigationMenu.Option>
<NavigationMenu.Option value="dark">Dark</NavigationMenu.Option>
</NavigationMenu.Options>
</NavigationMenu.Setting>
<NavigationMenu.Setting label="Motion">
<NavigationMenu.Options
aria-label="Motion"
value={motion}
onValueChange={(next) => setMotion(String(next))}
>
<NavigationMenu.Option value="full">Full</NavigationMenu.Option>
<NavigationMenu.Option value="reduced">Reduced</NavigationMenu.Option>
</NavigationMenu.Options>
</NavigationMenu.Setting>
<NavigationMenu.Footer>
<NavigationMenu.Hint keys={['↑', '↓']}>Move</NavigationMenu.Hint>
<NavigationMenu.Hint keys={['↵']}>Open</NavigationMenu.Hint>
<NavigationMenu.Hint keys={['Esc']}>Close</NavigationMenu.Hint>
</NavigationMenu.Footer>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
</NavigationMenu>
);
}Use it for a site's or an app's top-level destinations, where some of them open a panel of further links: a docs header, a product site, an app's launcher.
In island the panel is the bar grown larger rather than a box that appears under it, and its contents fade in once it has room. bar is a full-width header whose panel hangs below the triggers and moves between them. dock is an island at the foot of the window, with icon rows whose labels appear when pointed at.
For a sidebar of destinations beside the page, use Nav Rail. For a list of actions rather than places, use Menu.
Installation
npx shadcn@latest add https://panelui.dev/r/web/navigation-menu.jsonpnpm dlx shadcn@latest add https://panelui.dev/r/web/navigation-menu.jsonyarn dlx shadcn@latest add https://panelui.dev/r/web/navigation-menu.jsonbunx shadcn@latest add https://panelui.dev/r/web/navigation-menu.jsonThe source is copied into components/panelui/, where you can edit it.
Usage
import { NavigationMenu } from "@/components/panelui/navigation-menu"<NavigationMenu aria-label="Main">
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link href="/docs" active>Docs</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item value="more">
<NavigationMenu.Trigger>More</NavigationMenu.Trigger>
<NavigationMenu.Content>
<NavigationMenu.Card href="/install" tone="success" eyebrow="Start here">Install</NavigationMenu.Card>
<NavigationMenu.Pills>
<NavigationMenu.Pill href="https://github.com" external>GitHub</NavigationMenu.Pill>
</NavigationMenu.Pills>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
</NavigationMenu>Composition
<NavigationMenu>
<NavigationMenu.Brand />
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link />
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Trigger />
<NavigationMenu.Content>
<NavigationMenu.Profile />
<NavigationMenu.Card />
<NavigationMenu.Value />
<NavigationMenu.Pills>
<NavigationMenu.Pill />
</NavigationMenu.Pills>
<NavigationMenu.Group>
<NavigationMenu.Link />
</NavigationMenu.Group>
<NavigationMenu.Separator />
<NavigationMenu.Setting>
<NavigationMenu.Options>
<NavigationMenu.Option />
</NavigationMenu.Options>
</NavigationMenu.Setting>
<NavigationMenu.Footer>
<NavigationMenu.Hint />
</NavigationMenu.Footer>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Actions />
<NavigationMenu.Status />
</NavigationMenu>NavigationMenu.NavigationMenu— The menu: the bar, and the panel its triggers open.variantchooses island, bar or dock,sidewhich way the panel opens, andopenOnwhether a trigger opens on a press only or also under the pointer. PassvalueandonValueChangeto open a panel yourself, for a keyboard shortcut.NavigationMenu.Brand— The mark at the start of the bar, drawn in a round tile: an avatar or a logo. Withhrefit is a link home; without children it is the mark alone and needs anaria-label.NavigationMenu.List— The destinations and triggers, every one at full strength. A highlight appears under the one the pointer or the keyboard is on, travels between them, and is put away when neither is on the list.NavigationMenu.Item— One entry in the list. Give it avaluewhen it holds a trigger you want to open from outside.NavigationMenu.Link— A destination. In the bar it is a pill; mark the current page withactive. Inside a panel it is a row, with an optionaliconin a square of its own and adescriptionunder the label.NavigationMenu.Trigger— Opens its item's content. In an island it keeps a fill of its own, so it reads as a control rather than a destination. Passiconto draw one before the label, andhideChevronto drop the chevron after it.NavigationMenu.Content— What a trigger opens.classNamelays out the panel: its width, a grid, its padding. Its contents fade in together as the panel grows.NavigationMenu.Profile— Who or what the panel is about: a name, adescriptionunder it, and astatusat the end, such as a Badge.NavigationMenu.Card— A featured destination: a tile in a themetone, a smalleyebrowline, the title and an arrow. Only the tile carries the colour. Use one or two near the top of a panel, for where most people are going.NavigationMenu.Value— A value worth taking away, such as a command or an address, withactionsat its end. Put a Copy pill there.NavigationMenu.Pills— A row of pills that wraps when it runs out of room.NavigationMenu.Pill— A small round control: a button, or a link withhref.externaladds an arrow and opens the link in a new tab. With only aniconit is a round icon pill and needs anaria-label.NavigationMenu.Group— Rows under one small heading, given bylabel.NavigationMenu.Setting— A labelled row with a control at its end, for preferences kept in the menu. PutNavigationMenu.Optionsor a Switch in it.NavigationMenu.Options— A choice of a few options in one rounded track, for a preference kept in the menu. It is a radio group: the arrow keys move the choice.NavigationMenu.Option— One option in a track. Give it avalue.NavigationMenu.Separator— A rule between parts of a panel.NavigationMenu.Footer— The strip along a panel's foot, for keyboard hints.NavigationMenu.Hint— One keyboard hint: each of itskeysin a cap, then what they do.NavigationMenu.Actions— Controls at the end of the bar that are not destinations, such as sign-in buttons. They sit outside the list, so the highlight does not visit them.NavigationMenu.Status— A strip hanging under the bar that says what is happening now: anicon, a line, anactionlink and an optionalprogressmeter. Give each status its ownid: when theidchanges, the strip tucks up into the bar, changes out of sight and comes back down. It also tucks away while a panel is open, and whenhiddenis set.
Examples
Island
The bar holds an avatar, three destinations and a trigger. Pressing the trigger grows the bar into a panel: a profile, two cards, a command to copy, links out, two settings and a footer of hints.
'use client';
import { CheckIcon, CoinsIcon, ShareIcon, TerminalIcon } from 'lucide-react';
import { useState } from 'react';
import { Badge } from '@/components/panelui/badge';
import { NavigationMenu } from '@/components/panelui/navigation-menu';
const COMMAND = 'npx panelui-cli init';
export default function NavigationMenuOverview() {
const [copied, setCopied] = useState(false);
const [theme, setTheme] = useState('system');
const [motion, setMotion] = useState('full');
const copy = () => {
void navigator.clipboard?.writeText(COMMAND);
setCopied(true);
window.setTimeout(() => setCopied(false), 1600);
};
return (
<NavigationMenu aria-label="Main">
<NavigationMenu.Brand
href="#"
aria-label="Home"
icon={<img src="https://avatars.githubusercontent.com/u/127331761?v=4" alt="" />}
/>
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" active>
Docs
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Components</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Blocks</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item value="more">
<NavigationMenu.Trigger>v0.18</NavigationMenu.Trigger>
<NavigationMenu.Content className="w-[25rem]">
<NavigationMenu.Profile
description="Maintainer · PanelUI"
status={
<Badge variant="success" dot>
Taking contributions
</Badge>
}
>
Khalid Abdi
</NavigationMenu.Profile>
<NavigationMenu.Card href="#" icon={<TerminalIcon />} eyebrow="Start here">
Install PanelUI
</NavigationMenu.Card>
<NavigationMenu.Card href="#" icon={<CoinsIcon />} eyebrow="New in 0.18">
Currency Input
</NavigationMenu.Card>
<NavigationMenu.Value
actions={
<>
<NavigationMenu.Pill onClick={copy} icon={copied ? <CheckIcon /> : undefined}>
{copied ? 'Copied' : 'Copy'}
</NavigationMenu.Pill>
<NavigationMenu.Pill icon={<ShareIcon />} aria-label="Share" />
</>
}
>
<code className="font-mono text-sm">{COMMAND}</code>
</NavigationMenu.Value>
<NavigationMenu.Pills>
<NavigationMenu.Pill href="https://github.com/panel-ui/PanelUI" external>
GitHub
</NavigationMenu.Pill>
<NavigationMenu.Pill href="https://www.npmjs.com/package/panelui-web" external>
npm
</NavigationMenu.Pill>
<NavigationMenu.Pill href="#" external>
Changelog
</NavigationMenu.Pill>
</NavigationMenu.Pills>
<NavigationMenu.Separator />
<NavigationMenu.Setting label="Theme">
<NavigationMenu.Options aria-label="Theme" value={theme} onValueChange={(next) => setTheme(String(next))}>
<NavigationMenu.Option value="system">System</NavigationMenu.Option>
<NavigationMenu.Option value="light">Light</NavigationMenu.Option>
<NavigationMenu.Option value="dark">Dark</NavigationMenu.Option>
</NavigationMenu.Options>
</NavigationMenu.Setting>
<NavigationMenu.Setting label="Motion">
<NavigationMenu.Options
aria-label="Motion"
value={motion}
onValueChange={(next) => setMotion(String(next))}
>
<NavigationMenu.Option value="full">Full</NavigationMenu.Option>
<NavigationMenu.Option value="reduced">Reduced</NavigationMenu.Option>
</NavigationMenu.Options>
</NavigationMenu.Setting>
<NavigationMenu.Footer>
<NavigationMenu.Hint keys={['↑', '↓']}>Move</NavigationMenu.Hint>
<NavigationMenu.Hint keys={['↵']}>Open</NavigationMenu.Hint>
<NavigationMenu.Hint keys={['Esc']}>Close</NavigationMenu.Hint>
</NavigationMenu.Footer>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
</NavigationMenu>
);
}Header
variant="bar" spans the page and opens on hover as well as on a press. The panel hangs below the triggers and, as the pointer crosses from one trigger to the next, moves under it, resizes to its content and slides that content in from the side the pointer came from. NavigationMenu.Actions holds the buttons at the end.
'use client';
import {
BarChart3Icon,
BlocksIcon,
BoxIcon,
BrushIcon,
GitPullRequestIcon,
MessagesSquareIcon,
PaletteIcon,
ShapesIcon,
TerminalIcon,
} from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { NavigationMenu } from '@/components/panelui/navigation-menu';
export default function NavigationMenuMega() {
return (
<NavigationMenu variant="bar" aria-label="Site">
<NavigationMenu.Brand href="#" className="ps-2">
PanelUI
</NavigationMenu.Brand>
<NavigationMenu.List>
<NavigationMenu.Item value="library">
<NavigationMenu.Trigger>Library</NavigationMenu.Trigger>
<NavigationMenu.Content className="grid w-[34rem] grid-cols-2 gap-1">
<NavigationMenu.Link href="#" icon={<BoxIcon />} description="Eighty-four parts for React and Tailwind">
Components
</NavigationMenu.Link>
<NavigationMenu.Link href="#" icon={<BarChart3Icon />} description="Line, bar, sankey and twenty more">
Charts
</NavigationMenu.Link>
<NavigationMenu.Link href="#" icon={<BlocksIcon />} description="Screens assembled from the parts">
Blocks
</NavigationMenu.Link>
<NavigationMenu.Link href="#" icon={<ShapesIcon />} description="One stroke weight, every size">
Icons
</NavigationMenu.Link>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item value="learn">
<NavigationMenu.Trigger>Learn</NavigationMenu.Trigger>
<NavigationMenu.Content className="w-[26rem]">
<NavigationMenu.Card href="#" icon={<TerminalIcon />} eyebrow="Ten minutes">
Your first screen
</NavigationMenu.Card>
<NavigationMenu.Group label="Guides">
<NavigationMenu.Link href="#" icon={<PaletteIcon />} description="Tokens, themes and dark mode">
Theming
</NavigationMenu.Link>
<NavigationMenu.Link href="#" icon={<BrushIcon />} description="Building from parts, not styled divs">
Composition
</NavigationMenu.Link>
</NavigationMenu.Group>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item value="community">
<NavigationMenu.Trigger>Community</NavigationMenu.Trigger>
<NavigationMenu.Content className="w-[20rem]">
<NavigationMenu.Link href="#" icon={<GitPullRequestIcon />} description="Issues, pull requests, releases">
GitHub
</NavigationMenu.Link>
<NavigationMenu.Link href="#" icon={<MessagesSquareIcon />} description="Questions and show-and-tell">
Discussions
</NavigationMenu.Link>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Pricing</NavigationMenu.Link>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Actions className="ms-auto">
<Button variant="ghost" size="sm">
Sign in
</Button>
<Button size="sm">Get started</Button>
</NavigationMenu.Actions>
</NavigationMenu>
);
}Search
A trigger whose panel is a Command. The panel is as wide as the bar, so the bar only grows downwards into the search. keepMounted on the content mounts the Command with the page, so opening it does no work. The demo opens it with ⌘K or Ctrl+K by holding value, moves focus into the field when it opens, and passes bare to the Command so the panel draws the surface.
'use client';
import { BoxIcon, FileTextIcon, HashIcon, SearchIcon } from 'lucide-react';
import { useEffect, useRef, useState } from 'react';
import { Command } from '@/components/panelui/command';
import { NavigationMenu } from '@/components/panelui/navigation-menu';
const RESULTS = [
{ title: 'Navigation Menu', where: 'Components', icon: <BoxIcon /> },
{ title: 'Command', where: 'Components', icon: <BoxIcon /> },
{ title: 'Theming', where: 'Guides', icon: <FileTextIcon /> },
{ title: 'Upgrading to 1.x', where: 'Guides', icon: <FileTextIcon /> },
{ title: '--radius', where: 'Tokens', icon: <HashIcon /> },
];
export default function NavigationMenuSearch() {
const [value, setValue] = useState<string | null>(null);
const input = useRef<HTMLInputElement>(null);
// The field takes focus once the panel is open, so typing goes straight into it.
useEffect(() => {
if (value !== 'search') return;
const frame = requestAnimationFrame(() => input.current?.focus({ preventScroll: true }));
return () => cancelAnimationFrame(frame);
}, [value]);
// ⌘K or Ctrl+K grows the bar into the search, from anywhere on the page.
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
if (event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) {
event.preventDefault();
setValue((current) => (current === 'search' ? null : 'search'));
}
};
window.addEventListener('keydown', onKeyDown);
return () => window.removeEventListener('keydown', onKeyDown);
}, []);
return (
<NavigationMenu aria-label="Main" value={value} onValueChange={setValue}>
<NavigationMenu.Brand
href="#"
aria-label="Home"
icon={<img src="https://avatars.githubusercontent.com/u/127331761?v=4" alt="" />}
/>
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" active>
Home
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Docs</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Blocks</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item value="search">
<NavigationMenu.Trigger icon={<SearchIcon />} hideChevron>
Search
</NavigationMenu.Trigger>
{/* As wide as the bar, so the bar only grows downwards. Kept mounted, so opening it does no work. */}
<NavigationMenu.Content keepMounted>
<Command variant="compact" label="Search the docs" bare>
<Command.Input ref={input} placeholder="Search pages, parts, tokens" />
<Command.List>
{RESULTS.map((result) => (
<Command.Item key={result.title} icon={result.icon} subtitle={result.where}>
{result.title}
</Command.Item>
))}
<Command.Empty>Nothing matches that</Command.Empty>
</Command.List>
</Command>
<NavigationMenu.Footer>
<NavigationMenu.Hint keys={['↑', '↓']}>Move</NavigationMenu.Hint>
<NavigationMenu.Hint keys={['↵']}>Open</NavigationMenu.Hint>
<NavigationMenu.Hint keys={['⌘', 'K']}>Close</NavigationMenu.Hint>
</NavigationMenu.Footer>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
</NavigationMenu>
);
}Status
NavigationMenu.Status hangs a strip under the bar. Here it moves through three statuses every few seconds, each with its own id: it tucks up into the bar, changes out of sight, and comes back down. The one in progress carries a progress meter. While the page scrolls, hidden tucks it away, and it returns once the page settles.
'use client';
import { ArrowRightIcon, HammerIcon } from 'lucide-react';
import { useEffect, useState } from 'react';
import { NavigationMenu } from '@/components/panelui/navigation-menu';
const STATUSES = [
{
id: 'open',
icon: <span className="size-2 rounded-full bg-success" />,
text: 'Taking contributions',
action: 'Open an issue',
},
{
id: 'building',
icon: <HammerIcon />,
text: 'In progress: Date Picker',
action: 'See it',
progress: 0.7,
},
{
id: 'soon',
icon: <span className="size-2 rounded-[3px] bg-info" />,
text: 'Coming soon: Data Grid',
action: 'Follow',
},
];
export default function NavigationMenuStatusDemo() {
const [index, setIndex] = useState(0);
const [scrolling, setScrolling] = useState(false);
// A new status every few seconds.
useEffect(() => {
const timer = window.setInterval(() => setIndex((current) => (current + 1) % STATUSES.length), 4000);
return () => window.clearInterval(timer);
}, []);
// Tucked away while the page moves, and back once it settles.
useEffect(() => {
let settle = 0;
const onScroll = () => {
setScrolling(true);
window.clearTimeout(settle);
settle = window.setTimeout(() => setScrolling(false), 500);
};
window.addEventListener('scroll', onScroll, { passive: true });
return () => {
window.removeEventListener('scroll', onScroll);
window.clearTimeout(settle);
};
}, []);
const status = STATUSES[index]!;
return (
<NavigationMenu aria-label="Main">
<NavigationMenu.Brand
href="#"
aria-label="Home"
icon={<img src="https://avatars.githubusercontent.com/u/127331761?v=4" alt="" />}
/>
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" active>
Docs
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Components</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Blocks</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Blog</NavigationMenu.Link>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Status
id={status.id}
icon={status.icon}
progress={status.progress}
hidden={scrolling}
action={
<a href="#" className="inline-flex items-center gap-1">
{status.action}
<ArrowRightIcon className="size-3.5 rtl:-scale-x-100" />
</a>
}
>
{status.text}
</NavigationMenu.Status>
</NavigationMenu>
);
}Dock
variant="dock" sits at the foot of an app window and opens upwards. Its rows are icons; a label floats above each one when it is pointed at or reached with Tab, so the dock never changes width under the pointer. A dot marks the current one.
'use client';
import {
CalendarIcon,
FolderIcon,
HouseIcon,
InboxIcon,
LayoutGridIcon,
MusicIcon,
NotebookPenIcon,
TimerIcon,
} from 'lucide-react';
import { NavigationMenu } from '@/components/panelui/navigation-menu';
export default function NavigationMenuDock() {
return (
// A stage tall enough for the panel to open upwards above the dock.
<div className="flex min-h-[26rem] w-full items-end justify-center">
<NavigationMenu variant="dock" aria-label="Apps">
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" icon={<HouseIcon />} active>
Home
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" icon={<InboxIcon />}>
Inbox
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" icon={<CalendarIcon />}>
Calendar
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" icon={<FolderIcon />}>
Files
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item value="apps">
<NavigationMenu.Trigger icon={<LayoutGridIcon />}>More apps</NavigationMenu.Trigger>
<NavigationMenu.Content className="w-[20rem]">
<NavigationMenu.Card href="#" icon={<NotebookPenIcon />} eyebrow="Edited 2 min ago">
Notes
</NavigationMenu.Card>
<NavigationMenu.Card href="#" icon={<TimerIcon />} eyebrow="25:00 focus">
Timer
</NavigationMenu.Card>
<NavigationMenu.Card href="#" icon={<MusicIcon />} eyebrow="Paused">
Music
</NavigationMenu.Card>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
</NavigationMenu>
</div>
);
}Preferences
A settings panel for the signed-in person: a profile with their plan, cards for the account and billing, then NavigationMenu.Setting rows that each hold NavigationMenu.Options. The line under the menu reports what is chosen.
'use client';
import { CircleUserRoundIcon, CreditCardIcon, Settings2Icon } from 'lucide-react';
import { useState } from 'react';
import { NavigationMenu } from '@/components/panelui/navigation-menu';
import { Badge } from '@/components/panelui/badge';
export default function NavigationMenuPreferences() {
const [theme, setTheme] = useState('system');
const [density, setDensity] = useState('comfortable');
return (
<div className="flex flex-col items-center gap-4">
<NavigationMenu aria-label="Main">
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Link href="#" active>
Overview
</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Link href="#">Reports</NavigationMenu.Link>
</NavigationMenu.Item>
<NavigationMenu.Item value="you">
<NavigationMenu.Trigger icon={<Settings2Icon />}>You</NavigationMenu.Trigger>
<NavigationMenu.Content className="w-[22rem]">
<NavigationMenu.Profile description="mira@northwind.studio" status={<Badge variant="info">Team</Badge>}>
Mira Okafor
</NavigationMenu.Profile>
<NavigationMenu.Card href="#" icon={<CircleUserRoundIcon />} eyebrow="Name, photo, email">
Account
</NavigationMenu.Card>
<NavigationMenu.Card href="#" icon={<CreditCardIcon />} eyebrow="6 of 8 seats used">
Billing
</NavigationMenu.Card>
<NavigationMenu.Separator />
<NavigationMenu.Setting label="Theme">
<NavigationMenu.Options
aria-label="Theme"
value={theme}
onValueChange={(next) => setTheme(String(next))}
>
<NavigationMenu.Option value="system">System</NavigationMenu.Option>
<NavigationMenu.Option value="light">Light</NavigationMenu.Option>
<NavigationMenu.Option value="dark">Dark</NavigationMenu.Option>
</NavigationMenu.Options>
</NavigationMenu.Setting>
<NavigationMenu.Setting label="Density">
<NavigationMenu.Options
aria-label="Density"
value={density}
onValueChange={(next) => setDensity(String(next))}
>
<NavigationMenu.Option value="comfortable">Roomy</NavigationMenu.Option>
<NavigationMenu.Option value="compact">Compact</NavigationMenu.Option>
</NavigationMenu.Options>
</NavigationMenu.Setting>
<NavigationMenu.Footer>
<NavigationMenu.Hint keys={['Esc']}>Close</NavigationMenu.Hint>
</NavigationMenu.Footer>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
</NavigationMenu>
<p className="text-xs text-muted-foreground">
Theme: {theme} · Density: {density}
</p>
</div>
);
}API Reference
NavigationMenu
| Prop | Type | Default | Description |
|---|---|---|---|
variant | NavigationMenuVariant | 'island' | island is a floating pill that grows into its panel; dock is the same with icon rows whose labels appear when pointed at; bar is a full-width header with a panel that hangs below it. Default island. |
side | 'top' | 'bottom' | bottom | Which way the panel opens. Default bottom, or top for dock. |
openOn | 'press' | 'hover' | — | What opens a panel. press waits for a click, Enter or Space, and keeps the panel open until it is dismissed, so a pointer drifting off it while someone types or chooses does not close it. hover also opens it under the pointer and closes it when the pointer leaves. Default press for island and dock, hover for bar. |
className | string | — | |
barClassName | string | — | Classes for the bar that holds the list. |
NavigationMenu.List
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — |
NavigationMenu.Item
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — |
NavigationMenu.Trigger
| Prop | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | — | Drawn before the label. In a dock it is the whole row until pointed at. |
hideChevron | boolean | false | Hides the chevron after the label. |
className | string | — |
NavigationMenu.Content
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — |
NavigationMenu.Link
| Prop | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | — | Drawn before the label: in the bar, beside it; in a panel, in a square of its own. |
description | ReactNode | — | In a panel, a quieter line under the label. |
className | string | — |
NavigationMenu.Brand
| Prop | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | — | The mark: an image or an icon, drawn in a round tile. |
NavigationMenu.Card
| Prop | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | — | Drawn in the card's tile. |
tone | NavigationMenuTone | 'neutral' | The tile's colour, as a theme role. Default neutral. |
eyebrow | ReactNode | — | A small line above the title: "Start here", "New". |
className | string | — |
NavigationMenu.Group
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | The small heading over the group. |
NavigationMenu.Setting
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | What the control beside it sets: "Theme", "Labels". |
NavigationMenu.Hint
| Prop | Type | Default | Description |
|---|---|---|---|
keys | readonly string[] | — | The keys, each drawn in its own cap: ['⌘', 'K']. |
NavigationMenu.Profile
| Prop | Type | Default | Description |
|---|---|---|---|
description | ReactNode | — | A quieter line under the name: a role, a place, a plan. |
status | ReactNode | — | Something at the row's end, such as a Badge saying whether they are available. |
NavigationMenu.Value
| Prop | Type | Default | Description |
|---|---|---|---|
actions | ReactNode | — | Pills at the row's end that act on the value: a copy, a share. |
NavigationMenu.Options
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — |
NavigationMenu.Option
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — |
NavigationMenu.Status
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | '' | Which status this is. When it changes, the strip tucks up behind the bar, changes what it says out of sight, and comes back down. Content that changes under the same id, such as progress, updates in place. |
icon | ReactNode | — | Drawn before the line: a project's mark, a coloured dot for a state. |
action | ReactNode | — | At the strip's end, after a rule: usually a link such as "See it". |
progress | number | — | How far along, from 0 to 1, drawn as a short meter after the line. Leave it out for none. |
hidden | boolean | false | Tucks the strip away behind the bar, for example while the page scrolls. |
Every part also takes the props of the element it renders, and a className.
Notes
Opening
In island and dock a trigger opens on a press, and the panel stays open until a press outside, Escape or following a link closes it. A panel that holds a search field or settings must not close because the pointer drifted off it. In bar a trigger also opens after a short pause under the pointer, and the panel closes when the pointer leaves; delay and closeDelay set the two pauses, 60 and 120 milliseconds by default. Set openOn to choose either behaviour for any variant.
Moving from one trigger to the next while a panel is open swaps the panel's content without closing it. Focus returns to the trigger when it closes.
To open a panel from somewhere else, give its NavigationMenu.Item a value and hold value and onValueChange on the menu. That is how the Search example answers ⌘K.
Keyboard
Tab moves across the bar. Enter, Space or the Down arrow opens a trigger's panel, and Tab moves into it; there the arrow keys walk its links, and Escape closes it and returns focus to the trigger. The highlight follows focus from the keyboard as it follows the pointer.
The status strip
NavigationMenu.Status goes inside NavigationMenu, after the list; it is drawn under the bar rather than in it. It is a live region, so a screen reader announces a new status, and while it is tucked away it leaves the accessibility tree. Keep the line short: the strip is never wider than the bar, and a longer line is cut off with an ellipsis.
The panel's width
A panel is as wide as its content, and in island and dock never narrower than the bar it grows from. Set a width on NavigationMenu.Content to fix it, such as w-[22rem]. The panel stays inside the viewport and shrinks to fit a narrow one.
Reduced motion
With reduced motion set, the panel opens and changes size without animating, its contents appear without fading, and the highlight moves without travelling.
Accessibility
The root is a <nav> landmark, so give it an aria-label when the page has more than one. A link marked active carries aria-current="page". Each trigger reports its panel with aria-expanded. In a dock the labels are always in the accessibility tree, so an icon-only row is never nameless. NavigationMenu.Options is a radio group, and an icon-only NavigationMenu.Pill needs an aria-label. The highlight is decorative and hidden from assistive technology.
Built on
Base UI's NavigationMenu, for the triggers, hover intent, keyboard model, focus return and the size it measures for each panel. The panel's growth is a clip from the bar's measured shape to the panel's full size. Icons are whatever the app passes; the package does not ship an icon set.
Server Components
NavigationMenu is a client component. In a file that starts with "use client", write its parts with a dot, as on this page. A Server Component cannot read NavigationMenu.List off the import, so each part is also exported by name: NavigationMenuList is NavigationMenu.List, and so on for the others.
import { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuBrand, NavigationMenuActions, NavigationMenuCard, NavigationMenuGroup, NavigationMenuSetting, NavigationMenuSeparator, NavigationMenuFooter, NavigationMenuHint, NavigationMenuProfile, NavigationMenuValue, NavigationMenuPills, NavigationMenuPill, NavigationMenuOptions, NavigationMenuOption, NavigationMenuStatus } from "@/components/panelui/navigation-menu"