Navigation Menu
Navigate a website through links and animated shared panels.
Use NavigationMenu for website destinations, with direct links and expandable link panels. Use DropdownMenu for a menu of actions.
Basic usage#
Playground#
Anatomy#
Usage#
Basic#
Combine expandable panels with direct links. Use NavigationMenu.Content for each panel and NavigationMenu.Link for its destinations.
Controlled state and disabled items#
Use stable item values with value and onValueChange. Set the value to null to close. Disabled or removed items cannot keep a panel open. defaultValue opens an item after hydration.
Orientation#
Set orientation="vertical" for a vertical list. Use placement="right" to place its panels beside the triggers.
RTL#
Set dir="rtl" on the surrounding container for right-to-left navigation.
Custom links#
Use linkRender for a router’s link component. Forward the supplied attributes, events, children, object style and ref to the anchor. active marks the current page with aria-current="page". closeOnClick defaults to false; enable it when activation should also close the panel. A cancelled click does not request closing.
Keyboard interaction#
Arrow keys along the list axis move focus without opening a panel. Home and End focus the first and last enabled navigation controls. Enter and Space activate a trigger. ArrowDown opens a horizontal menu and enters its content; ArrowRight does the same for a vertical LTR menu, and ArrowLeft for RTL.
Tab and Shift+Tab preserve the order between the trigger, its portaled content and the following navigation control. Arrow keys and Home/End move between panel links, while inputs retain their editing keys. Escape closes the panel and returns focus to its trigger. Outside click and focus close the panel without taking focus away from the destination.
The root renders a navigation landmark. Give it an accessible name when the page has several navigation landmarks. This version supports one level of panels.
Attributes#
data-disabledSlot: navigation-menu, navigation-menu-item, navigation-menu-trigger, navigation-menu-linkDescription: Present when the component, slot, or item is disabled.data-orientationSlot: navigation-menu, navigation-menu-list, navigation-menu-contentDescription: Stores the rendered orientation (horizontal or vertical).data-expandedSlot: navigation-menu-item, navigation-menu-trigger, navigation-menu-trigger-icon, navigation-menu-contentDescription: Present when the panel, accordion, or menu is expanded.data-closedSlot: navigation-menu-contentDescription: Present when disclosure or transition content is closed.data-activeSlot: navigation-menu-linkDescription: Present when the item or trigger is active.Props#
NavigationMenu#
Renders a <nav> element by default.
List#
Renders a <ul> element by default.
Item#
Renders a <li> element by default.
Trigger#
Renders a <button> element by default.
Content#
Renders a <div> element by default.
Link#
Renders a <a> element by default.