NavigationMenu
Navigate a website through links and animated shared panels.
Anatomy#
Usage#
Use NavigationMenu for website destinations, with direct links and expandable link panels. Use DropdownMenu for a menu of actions. Use Tabs for peer panels that stay on the same page.
Panels and links#
Combine expandable panels with direct links:
NavigationMenu.Content: holds an item’s expandable panel.NavigationMenu.Link: renders a destination insideContentor directly insideNavigationMenu.Item.active: marks the current page witharia-current="page".closeOnSelect: clicking a link closes the open panel by default. SetcloseOnSelect={false}to keep it open, or callpreventDefault()in a click handler to cancel closing.disabled: removeshreffrom a link and setsaria-disabled.
The root renders a <nav> landmark. Give it an aria-label when the page has multiple navigation landmarks. NavigationMenu supports one level of panels.
Controlled state#
Give each item with content a stable value:
valueandonValueChange: control the open item.onValueChangereceives the itemvalueto open ornullto close; write it back tovalue.nullvsundefined: passvalue={null}to keep a controlled menu closed;value={undefined}leaves it uncontrolled. A value matching no enabled item with content also leaves the menu closed.defaultValue: opens an initial item after hydration in uncontrolled mode.disabled: on the root, disables every trigger and link and closes any open panel; on anItem, disables only that item’s trigger or direct links.
Orientation#
Set orientation="vertical" for a vertical list. Use placement="right" to place its panels beside the triggers.
Hover and positioning#
openDelay(default50ms): delays hover opening when no panel is open. Hovering another trigger while a panel is open switches immediately, and click or keyboard activation never waits.closeDelay(default50ms): delays closing after the pointer leaves the menu. The panel stays open while focus is inside it.- Positioning:
placement(default'bottom'),align(default'center'),gutter(default8),shift,flip, andslideposition the shared panel relative to the active trigger.
RTL#
Set dir="rtl" on a surrounding container for right-to-left navigation. Arrow keys follow that direction, including the key that opens a panel from a vertical menu.
Custom links#
Use linkRender for a router’s link component. Forward the supplied attributes, events, children, object style, and ref to the anchor.
Keyboard interaction#
- Trigger list: 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.
- Opening panels: ArrowDown opens a horizontal menu and enters its content; ArrowRight does the same for a vertical LTR menu, and ArrowLeft for RTL.
- Inside panels: Tab and Shift+Tab preserve focus order between the trigger, its portaled content, and the next navigation control. Arrow keys and Home/End move between panel links, while inputs retain their editing keys.
- Dismissal: Escape closes the panel and returns focus to its trigger. Outside click and focus close the panel without stealing focus from the destination.
Examples#
Basic#
Combine dropdown panels, direct links, and active state on the current page.
Controlled#
Control the active item with value and onValueChange (pass null to close). Disabled items
cannot open.
Vertical#
Stack triggers in a vertical list and place panels to the right.
Custom links#
Forward NavigationMenu link props through Solid Router’s A. Keep href on NavigationMenu.Link.
RTL#
Wrap the menu in dir="rtl". Triggers, panels, and links follow the writing direction without extra
props.
API Reference#
Attributes#
data-disableddata-orientationdata-expandeddata-closeddata-activeProps#
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.