Overlays

Menu

A popover anchored to its button, with separators, group labels, shortcuts, checks and destructive items.

Examples

Anatomy

button[popovertarget]The invoker; it becomes the menu's anchor.
.menu[popover]The panel, anchored below the invoker and flipped when clipped.
> button, > aItems, full width. A trailing <kbd> is pushed to the end as a shortcut hint.
> h6Optional group label.
> hrOptional separator, edge to edge.

API

AttributeValuesDescription
popoverbooleanRequired. Auto popovers close on Esc, on an outside click, and when another menu opens.
popovertarget<id>On the invoker: toggles and anchors the menu.
aria-pressedtruefalseOn an item: reserves a check column; true shows a ✓ and announces the item as pressed.
data-tonedangerOn an item: colours its text, for destructive actions.
data-closebooleanOn an item: aequitas.js hides the menu when it is clicked.

Behaviour

A click on a [data-close] item hides the menu, and aria-expanded on the invoker follows the menu as it opens and closes. Without it, popovertarget still opens and closes the menu natively, but items leave it open until you hide it.

From aequitas.js. It initialises itself and enhances markup added later on its own, so it works the same in an SPA.

Accessibility

  • The items are plain buttons in tab order. Only add role="menu" and role="menuitem" if you also script arrow-key focus, since those roles promise it.
  • A toggle item is a <button aria-pressed>, which every screen reader announces as pressed or not. role="menuitemcheckbox" with aria-checked also draws the check, but it is only valid inside a role="menu".
  • Clicking an item does not close the menu by itself: add data-close, or call hidePopover() in your handler.
KeyEffect
Enter / SpaceOn the invoker: toggles the menu; on an item: activates it (native).
Tab / ShiftTabMoves between items. There is no arrow-key navigation.
EscCloses the menu (native popover).
Jump to
ProportionFoundations
MaterialFoundations
PresetsFoundations
ShellLayouts · Application
Container and stacksLayouts · Pages
SplitLayouts · Pages
Grid, bento, masonryLayouts · Pages
Switcher and rowLayouts · Pages
↑↓Move↵OpenescClose