Navigation Menu
The main navigation of a site: a row of links, some of which open a panel of choices. Hover, click or use the arrow keys; the raised pill follows you, and the panel reshapes itself to fit what it holds.
Install
npx shadcn@latest add @nelumbo/navigation-menuProduct site header
Three panels and two plain links. Move between Products, Solutions and Resources: the surface springs to the size of the next panel and its content slides in from the side you came from. Pricing is the current page (aria-current).
Panels under their own items
viewport={false} drops the shared surface: each panel is its own popover under its item, which suits a short menu. Add NavigationMenuIndicator for a small notch that springs between triggers.
Keyboard
Tab moves into the menu and then out of it. Left and Right move between triggers and links, Enter or Space opens a panel, Tab moves into it and Tab and the arrow keys move through its links, and Escape closes the panel and returns to its trigger.
Usage
import { NavigationMenu, NavigationMenuContent, NavigationMenuFeatured, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuRichLink, NavigationMenuTrigger, navigationMenuTriggerStyle,} from "@/components/ui/navigation-menu"<NavigationMenu> <NavigationMenuList> <NavigationMenuItem> <NavigationMenuTrigger>Products</NavigationMenuTrigger> <NavigationMenuContent> <div className="grid gap-2 sm:w-[37rem] sm:grid-cols-[1fr_13rem]"> <ul className="grid gap-1"> <li> <NavigationMenuRichLink asChild icon="bolt" title="Automations" description="Run work on a schedule."> <Link href="/automations" /> </NavigationMenuRichLink> </li> </ul> <NavigationMenuFeatured asChild icon="stars" title="Nelumbo 2.0" description="What's new."> <Link href="/new" /> </NavigationMenuFeatured> </div> </NavigationMenuContent> </NavigationMenuItem> <NavigationMenuItem> <NavigationMenuLink asChild active={pathname === "/pricing"} className={navigationMenuTriggerStyle()}> <Link href="/pricing">Pricing</Link> </NavigationMenuLink> </NavigationMenuItem> </NavigationMenuList></NavigationMenu>| Prop | Type | Default | The list, items, triggers, content, link, indicator and viewport pass every other Radix prop through. Below the sm breakpoint the menu fills the width, the track wraps, and panels become a single column. |
|---|---|---|---|
| viewport | boolean | true | NavigationMenu: render panels in one shared surface that morphs between them; false opens each under its item |
| value / defaultValue / onValueChange | string | Radix: the open item, controlled or not | |
| delayDuration / skipDelayDuration | number | 200 / 300 | Radix: hover open delay, and the window in which moving to another trigger opens it at once |
| active | boolean | false | NavigationMenuLink: the current page; sets aria-current and an inverse fill |
| icon | IconName | NavigationMenuRichLink and NavigationMenuFeatured: the Material Symbol | |
| title / description | ReactNode | NavigationMenuRichLink and NavigationMenuFeatured: the text | |
| asChild | boolean | false | Link parts: render your router's Link as the only child |