Overview
NavigationMenu is a Base UI-powered navigation system for building complex menu structures with dropdown content panels.
- Use it for site-wide navigation with nested content.
- Supports keyboard navigation and hover interactions.
- Includes automatic viewport positioning for dropdown panels.
Installation
Import
Basic Example
Advanced Example
Size Scale
NavigationMenu supports xs | sm | md | lg | xl sizing that affects trigger and content sizing.
API Reference
NavigationMenu
Root menu container with size context.Size of the navigation menu:
xs | sm | md | lg | xl.NavigationMenuList
Horizontal list container for menu items.NavigationMenuItem
Individual menu item that can contain a trigger or direct link.Unique identifier for the menu item.
NavigationMenuTrigger
Interactive trigger button with dropdown arrow indicator.Size override for the trigger.
NavigationMenuContent
Dropdown content panel positioned below the trigger.Size override for the content.
NavigationMenuLink
Direct navigation link within menu or content.Size override for the link.
Whether this link represents the current page.
NavigationMenuViewport
Positioned container for dropdown content (automatically included in root).NavigationMenuIndicator
Animated active state indicator (optional).NavigationMenuArrow
Pointing arrow for dropdown content (optional).NavigationMenuBackdrop
Overlay backdrop for mobile or modal contexts (optional).Accessibility
- Base UI handles ARIA menu semantics and keyboard navigation.
- Use clear, descriptive labels for triggers.
- Ensure dropdown content is keyboard accessible.
- Support both hover and click interactions for flexibility.
SSR and RSC Notes
- NavigationMenu is client-interactive (
"use client"). - The viewport portal renders content outside the main tree for positioning.
- Use client boundaries when integrating into server components.
Styling and Tokens
- Default styles use semantic tokens (
bg-background,text-foreground,hover:bg-muted). - Trigger includes automatic chevron rotation on open state.
- Content panels can be styled with grid layouts for multi-column menus.
Troubleshooting
- Dropdown not appearing: ensure
NavigationMenuContentis inside aNavigationMenuItemwith aNavigationMenuTrigger. - Content misaligned: the viewport is automatically positioned; avoid custom absolute positioning.
- Keyboard navigation broken: verify Base UI event handlers are not prevented.