A collection of links for navigating websites.
Can be controlled or uncontrolled.
Flexible layout structure with managed tab focus.
Supports submenus.
Optional active item indicator.
Full keyboard navigation.
Exposes CSS variables for advanced animation.
Supports custom timings.
Install the component from your command line.
Import all parts and piece them together.
Contains all the parts of a navigation menu.
Signifies a submenu. Use it in place of the root part when nested to create a submenu.
Contains the top level menu items.
A top level menu item, contains a link or trigger with content combination.
The button that toggles the content.
Contains the content associated with each trigger.
A navigational link.
An optional indicator element that renders below the list, is used to highlight the currently active trigger.
An optional viewport element that is used to render active content outside of the list.
You can create a vertical menu by using the orientation prop.
Use the Viewport part when you need extra control over where Content is rendered. This can be helpful when your design
requires an adjusted DOM structure or if you need flexibility to achieve advanced animation.
Tab focus will be maintained automatically.
You can use the optional Indicator part to highlight the currently active Trigger, this is useful when you want to provide
an animated visual cue such as an arrow or highlight to accompany the Viewport.
Create a submenu by nesting your NavigationMenu and using the Sub part in place of its Root.
Submenus work differently to Root navigation menus and are similar to Tabs in that one item should always be active, so be
sure to assign and set a defaultValue.
If you need to use the Link component provided by your routing package then we recommend composing with NavigationMenu.Link via a custom component.
This will ensure accessibility and consistent keyboard control is maintained. Here's an example using Next.js:
We expose --radix-navigation-menu-viewport-[width|height] and data-motion['from-start'|'to-start'|'from-end'|'to-end'] attributes
to allow you to animate Viewport size and Content position based on the enter/exit direction.
Combining these with position: absolute; allows you to create smooth overlapping animation effects when moving between items.
Adheres to the navigation role requirements.
NavigationMenu should not be confused with menubar, although this primitive shares the name menu in the colloquial sense to refer to a set of navigation links, it does not use the WAI-ARIA menu role.
This is because menu and menubars behave like native operating system menus most commonly found in desktop application windows, as such they feature complex functionality like composite focus management and first-character navigation.
These features are often considered unnecessary for website navigation and at worst can confuse users who are familiar with established website patterns.
See the W3C Disclosure Navigation Menu example for more information.
It's important to use NavigationMenu.Link for all navigational links within a menu, this not only applies to the main list
but also within any content rendered via NavigationMenu.Content. This will ensure consistent keyboard interactions and accessibility
while also giving access to the active prop for setting aria-current and the active styles.
See this example for more information on usage with third party routing components.