Navigation Menu
A collection of links for navigating websites and React applications. Built with Radix UI NavigationMenu for keyboard navigation and screen reader accessibility.
You know those smooth navigation menus on modern websites? The ones where you hover and get those nice dropdown panels with organized links? That's what navigation menus do - they give you that polished, professional nav experience.
Complete navigation with mega menu
Full-featured navigation with organized content sections:
Built on Radix UI NavigationMenu with full keyboard support, proper focus management, and all the accessibility features users expect from modern navigation.
npx shadcn@latest add navigation-menu
Why navigation menus work so well
Regular dropdowns are fine, but navigation menus take it up a notch with better UX patterns:
- Organized content - Group related links logically with visual hierarchy
- Rich previews - Show descriptions, icons, or featured content
- Smooth interactions - Hover delays and animations that feel natural
- Keyboard friendly - Arrow keys, tab navigation, escape to close
- Touch optimized - Works great on mobile and tablets
- Screen reader ready - Proper ARIA labels and announcements
Perfect for modern websites
Works best when you're building something that needs organized navigation - marketing sites, documentation, SaaS apps, e-commerce. The navigation menu gives you that professional polish users expect from quality websites.
Drop it into any React or Next.js project where you want navigation that actually enhances the user experience instead of getting in their way.
Powered by Radix UI
This component is built on top of Radix UI's NavigationMenu primitive, which means you get:
- Managed focus - Tab focus is handled automatically between triggers and content
- Flexible viewport - Render content outside the list for advanced layouts
- Animation variables - CSS variables for viewport dimensions during animations
- Motion data attributes - Know which direction content is entering/exiting
- Submenu support - Nest navigation menus for complex hierarchies
- Delay management - Smart hover delays to prevent accidental triggers
API Reference
NavigationMenu
The root container that manages focus and keyboard navigation.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
orientation | "horizontal" | "vertical" | "horizontal" | Menu orientation |
children | React.ReactNode | - | NavigationMenuList component |
NavigationMenuList
Container for all menu items, handles layout and spacing.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | NavigationMenuItem components |
NavigationMenuItem
Individual menu item that can trigger content or be a direct link.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | NavigationMenuTrigger and/or NavigationMenuContent |
NavigationMenuTrigger
The clickable element that opens dropdown content.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | Trigger content (text, icons) |
NavigationMenuContent
The dropdown panel that appears when trigger is activated.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | Content for the dropdown panel |
NavigationMenuLink
Wrapper for links within navigation content, provides styling and accessibility.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
asChild | boolean | false | Pass styling to child element |
children | React.ReactNode | - | Link content |
NavigationMenuIndicator
Visual indicator that follows active menu items. Add this to create an underline or arrow that animates between triggers.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
forceMount | boolean | - | Force mount when closed |
Data attributes:
[data-state]
: "visible" | "hidden"[data-orientation]
: "horizontal" | "vertical"
NavigationMenuViewport
Container that handles content positioning and animations. Radix provides CSS variables you can use for smooth size transitions.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional CSS classes |
forceMount | boolean | - | Force mount when closed |
CSS variables:
--radix-navigation-menu-viewport-width
: Width of active content--radix-navigation-menu-viewport-height
: Height of active content
Helper Functions
navigationMenuTriggerStyle()
Pre-styled classes for consistent trigger appearance.
import { navigationMenuTriggerStyle } from "@/components/ui/navigation-menu"
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
About
</NavigationMenuLink>
Keyboard Navigation
Key | Action |
---|---|
Tab | Move focus to next trigger or out of menu |
Shift + Tab | Move focus to previous trigger |
Enter / Space | Open focused trigger's content |
Arrow Down | Move focus to content or next link |
Arrow Up | Move focus to previous link |
Arrow Left | Move to previous trigger |
Arrow Right | Move to next trigger |
Escape | Close content and return focus |
Home | Focus first trigger |
End | Focus last trigger |
Content Layout Patterns
Layout | Use Case | Grid Classes |
---|---|---|
Single Column | Simple link lists | grid gap-3 p-4 |
Two Columns | Organized categories | grid-cols-2 gap-3 p-4 |
Featured + Links | Highlight key content | grid-cols-[.75fr_1fr] |
Mega Menu | Complex navigation | grid-cols-4 gap-4 p-6 |
Build navigation that guides users
- Keep it scannable - Group related links, use clear labels
- Show what's important - Featured content, descriptions, icons
- Test on devices - Make sure touch targets are good on mobile
- Handle states - Active pages, hover effects, loading states
- Optimize timing - Use
delayDuration
andskipDelayDuration
props for natural hover behavior - Progressive disclosure - Don't overwhelm with too many options
- Test accessibility - Keyboard navigation, screen readers, focus management
- Use the indicator - Visual feedback helps users track where they are
- Animate thoughtfully - Use motion data attributes for directional animations
Menubar
A horizontal menu bar component for React and Next.js applications. Perfect for desktop-style interfaces with File, Edit, View menus and keyboard shortcuts.
Pagination
Navigation component for splitting large datasets across multiple pages. Built for React applications with Next.js integration and TypeScript support.