Navigation Menu
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 direct links#
Combine expandable panels with direct links. Use NavigationMenu.Content for each panel and
NavigationMenu.Link for its destinations; a link can also sit directly in a NavigationMenu.Item.
active marks the current page with aria-current="page". closeOnSelect defaults to false;
enable it to close the panel on activation. A click handler that calls preventDefault() cancels
the close. A disabled link loses its href and gets aria-disabled.
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.
Controlled state#
Give each item a stable value, then control the open item with value and onValueChange.
onValueChange receives the value of the item to open, or undefined to close, and you write it
back to value. A value that matches no enabled item with content leaves the menu closed, so
disabled or removed items cannot keep a panel open. For uncontrolled state, defaultValue opens an
item after hydration. disabled on the root disables every trigger and link and closes the
open panel; on an Item it 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 timing and positioning#
Panels open on hover after openDelay (default 50 ms) while no panel is open; hovering another
trigger while a panel is open switches immediately, and click or keyboard activation never waits.
The open panel closes closeDelay (default 50 ms) after the pointer leaves the menu, and stays
open while focus is inside it. placement (default 'bottom'), align (default 'center'),
gutter (default 8), shift, flip, and slide position 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#
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.
Examples#
Product and docs header#
Mix a two-column product panel, a shorter guides panel, and a direct Documentation link. Mark the
current page with active.
Open the account panel from page state#
Drive the open item with value and onValueChange. Close with null. A disabled Billing item
cannot stay open.
Vertical docs navigation#
Stack triggers in a vertical list and place panels to the right.
Route documentation links#
Forward NavigationMenu link props through Solid Router’s A. Keep href on NavigationMenu.Link.
Inherit RTL for a product header#
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.