ReferenceMenus
media-menu
A composable menu component for settings, option selection, and actions
Import
Anatomy
<media-menu> is the root menu and its one positioned popup. The root and nested <media-menu-content> elements are its direct children and share that popup.
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.
To create a submenu, add another <media-menu-content> as a sibling, give it an id, and point the parent <media-menu-item> at it with commandfor.
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.
The generated radio group publishes its state to the <media-menu> that contains it. Add an element with data-part="hint" inside the parent <media-menu-item> and the menu writes the selected label into it:
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 <media-menu> receives data-open, data-side, and data-align. Each <media-menu-content> receives menu state such as data-open and data-submenu; a content element 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 <media-menu-group-label> inside grouped choices so the group receives an accessible label.
Examples
Basic usage
API Reference
media-menu
Root menu state and positioned popup. Content pages are direct children.
Props
State
CSS custom properties
media-menu-checkbox-item
Menu item that toggles checked when activated and leaves the menu open. The element itself takes
role="menuitemcheckbox".
Props
Data attributes
media-menu-content
One accessible menu page. Root and nested pages are sibling children of <media-menu>.
media-menu-group
Groups related menu items; the element itself takes role="group". A <media-menu-group-label> child names the
group unless it already has an aria-label or aria-labelledby.
media-menu-group-label
Non-interactive label that names its enclosing <media-menu-group> or <media-menu-radio-group>.
media-menu-item
Menu action; the element itself takes role="menuitem". Activation fires a cancelable select event and then closes
the menu, unless commandfor names a nested <media-menu-content> page to open instead.
Props
Data attributes
media-menu-item-indicator
Decorative checked-state mark inside a menu item, hidden from assistive technology. It stays hidden unless
checked or force-mount is set; option radio groups set checked on the indicators in the items they generate.
Props
media-menu-radio-group
Group of mutually exclusive <media-menu-radio-item> children; the element itself takes role="group".