Menus
On this page
A menu puts several actions behind one button: the actions for a row, bulk actions for a list, or the less common actions on a detail page. The kit opens, closes and positions it, and handles the keyboard.


Figure 1: An open menu with a group label, two actions, a divider and a destructive action
<div class="ph-menu-wrap">
<button type="button" class="ph-btn" data-ph-menu="order-menu">Actions</button>
<div class="ph-menu ph-menu--end" role="menu" id="order-menu" hidden>
<div class="ph-menu-label">Orders</div>
<button type="button" role="menuitem">Export CSV</button>
<button type="button" role="menuitem">Refresh</button>
<div class="ph-menu-sep" role="separator"></div>
<button type="button" role="menuitem" class="ph-menu-item--danger">Clear history…</button>
</div>
</div>
| Class or attribute | What it does |
|---|---|
.ph-menu-wrap | Wraps the trigger and the menu so the menu opens under the trigger |
data-ph-menu="<id>" | On the trigger: opens the menu with that id |
.ph-menu | The menu. Give it role="menu", an id and hidden. |
.ph-menu--end | Lines the menu up with the trigger's right edge (for triggers near the right of the page) |
role="menuitem" | Each action (a <button> or <a>) |
.ph-menu-label | A small heading for a group of items |
.ph-menu-sep | A divider between groups |
.ph-menu-item--danger | Red text for destructive actions |
Keyboard
| Key | On the trigger | In the open menu |
|---|---|---|
| Click, Enter or Space | Opens or closes the menu | Chooses the item and closes the menu |
| Down arrow / Up arrow | Opens the menu | Moves to the next / previous item |
| Home / End | Moves to the first / last item | |
| Esc | Closes the menu and returns focus to the trigger | |
| Tab | Closes the menu |
Clicking outside also closes it. Disabled items (disabled or aria-disabled="true") are skipped.
The kit sets aria-haspopup, aria-expanded and aria-controls on the trigger.
Guidelines
- An icon-only trigger ("More actions", three dots) needs an
aria-label. - End an item's label with "…" when it opens a dialog or asks for confirmation.
- Put destructive items last, after a divider, and confirm them.
- Don't put the page's primary action in a menu.
Related
- Buttons
- Toolbar and search
- Dialogs and drawers: confirming destructive actions