ReferenceMenus
Menu
A composable menu component for settings, option selection, and actions
Import
Anatomy
A root menu owns one positioned Popup. Nested Content elements share that Popup with the root Content.
Behavior
Menus open from a trigger and close when you select an item, click outside, move focus away, or press Escape. Root menus use side and align as their preferred placement. When the preferred side overflows the positioning boundary, the menu uses the opposite side if it has more space.
Root menus inside a player container join its popup group. Opening one closes any other root menu or popover that is open in the same container. Submenus remain part of their root menu instead of registering separately.
Create a submenu by nesting another Menu.Root in the parent Menu.Content; its Menu.Trigger behaves as a parent item and its Menu.Content becomes the active Content.
Media option groups share their option state with the enclosing menu: the selected value, and whether the options are disabled, hidden, or available. The menu’s trigger inherits the disabled and hidden state and exposes data-availability, and the menu closes if its options disappear while open. See PlaybackRateRadioGroup, QualityRadioGroup, AudioTrackRadioGroup, and CaptionsRadioGroup.
Wrap a submenu’s Menu.Trigger and Menu.Content in the group’s Root part, and render its Value part inside the trigger to show the current selection:
Styling
Use data attributes to style open state, highlighted items, selected radio items, and submenu views:
data-highlighted identifies the current menu item. Its value is "pointer" when pointer movement caused the highlight and an empty string for other highlights, including keyboard navigation and type-ahead search. Use [data-highlighted] to match any highlighted item or [data-highlighted=""] to match highlights that were not caused by pointer movement.
The root Menu.Popup receives data-open, data-side, and data-align. Each Menu.Content receives menu state such as data-open and data-submenu; a Content with an open logical child receives data-child-open.
Every navigable item receives data-item. Use [data-item] when one rule should target regular, radio, checkbox, and submenu-trigger items together.
Accessibility
Menu content renders with role="menu". Items use menuitem, menuitemradio, or menuitemcheckbox roles. Radio and checkbox items reflect selection with aria-checked.
Keyboard controls:
- Enter / Space: Select the highlighted item.
- Arrow Up / Arrow Down: Move between items.
- Arrow Right: Open a submenu.
- Arrow Left: Return to the parent menu.
- Escape: Close the root menu or return from a submenu.
Use Menu.GroupLabel inside grouped choices so the group receives an accessible label.
Examples
Basic usage
API Reference
Root
Props
State
render, className, and style props.
CSS custom properties
CheckboxItem
A checkbox-style menu item. Renders a <div> with role="menuitemcheckbox".