Navigation Menu
Site navigation with menus that morph from one to the next, on the menu material.
"use client"
import { AppWindowIcon, BookOpenIcon, LayoutGridIcon, PaletteIcon } from "lucide-react"
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
} from "@/components/ui/navigation-menu"
const docs = [
{ title: "Installation", description: "Add the registry and the macOS theme.", icon: BookOpenIcon },
{ title: "Theming", description: "Accent colors, appearance and materials.", icon: PaletteIcon },
]
const components = [
{ title: "Window", description: "Title bars, traffic lights and toolbars.", icon: AppWindowIcon },
{ title: "Dock", description: "Magnification, running dots and badges.", icon: LayoutGridIcon },
]
function Links({ items }: { items: typeof docs }) {
return (
<ul className="grid w-[340px] gap-0.5">
{items.map((item) => (
<li key={item.title}>
<NavigationMenuLink href="#" className="items-start">
<item.icon className="mt-0.5 text-mac-accent" />
<span className="flex flex-col gap-0.5">
<span className="font-semibold">{item.title}</span>
<span className="text-mac-subheadline text-mac-label-secondary">{item.description}</span>
</span>
</NavigationMenuLink>
</li>
))}
</ul>
)
}
export default function NavigationMenuDemo() {
return (
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger>Getting Started</NavigationMenuTrigger>
<NavigationMenuContent>
<Links items={docs} />
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuTrigger>Components</NavigationMenuTrigger>
<NavigationMenuContent>
<Links items={components} />
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink href="#" className="h-7 rounded-full px-3 font-medium">
Blocks
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui/navigation-menuThe first install also adds the macOS theme. See Installation to set up the registry.
Usage
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger } from "@/components/ui/navigation-menu"
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger>Components</NavigationMenuTrigger>
<NavigationMenuContent>
<NavigationMenuLink href="/docs/components/window">Window</NavigationMenuLink>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>API Reference
Every part forwards the props of the underlying Base UI Navigation Menu part. The props below are the ones CupertinoUI adds or changes.
NavigationMenu
| Prop | Type | Description |
|---|---|---|
align | "start" | "center" | "end"Default: "start" | How the menu lines up with its trigger. |
className | string | Extra classes, merged with the component's own. |