Navigation Menu
Group related destination links in site navigation.
Preview
Installation
pnpm dlx shadcn@latest add https://migoy.stanleyaf.com/r/navigation-menu.jsonInstalls the Radix Navigation Menu primitive, Lucide, and Migoy Button.
Usage
import {
NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuLink,
navigationMenuTriggerStyle,
} from '@/components/ui/navigation-menu';
<NavigationMenu aria-label="Workspace navigation">
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuLink href="/projects" className={navigationMenuTriggerStyle()}>
Projects
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>Composition
NavigationMenu
├── NavigationMenuList
│ ├── NavigationMenuItem
│ │ └── NavigationMenuLink
│ ├── NavigationMenuItem
│ │ ├── NavigationMenuTrigger
│ │ └── NavigationMenuContent
│ │ └── NavigationMenuLink (one or more)
│ └── NavigationMenuIndicator (optional)
└── NavigationMenuViewport (rendered automatically by default)Use a link for a direct destination. Pair a trigger with content in the same item to reveal a group of links. Put the optional indicator inside the list. Set viewport={false} to position panels below the navigation without the shared viewport.
Accessibility
Give each navigation landmark a distinct label when the page has multiple navigation regions. Use active on the link for the current page. The link keeps the selected colors on hover. Unselected links use accent on hover, and open triggers use accent while their panel is visible. Tab into the navigation, use Left and Right to move across the top-level items, and use Down from a trigger to enter its panel. Escape closes the panel and returns focus to its trigger.
API
| Part | Props |
|---|---|
NavigationMenu | Radix Root props, plus viewport (default true) |
| List, Item, Trigger, Content, Link, Indicator, Viewport | Props of the corresponding Radix primitive |
navigationMenuTriggerStyle() | Returns the Migoy Button styling for top-level navigation links |
Based on shadcn Navigation Menu.