domestic-ui GitHub

Menu button

A button that opens a menu of actions.

Where a menu button is used A menu button is the Actions button at the end of a table row, opening a list of actions under it.

Live example

Actions menu

<dui-menu>
  <button type="button" popovertarget="row-actions">Actions</button>
  <div id="row-actions" popover data-popover>
    <button type="button">Edit</button>
    <button type="button">Duplicate</button>
    <button type="button">Archive</button>
    <hr>
    <button type="button">Delete</button>
  </div>
</dui-menu>
<p role="status" id="menu-result"></p>
<button type="button" popovertarget="account-links">Account</button>
<div id="account-links" popover data-popover>
  <nav aria-label="Account" data-nav>
    <ul>
      <li><a href="#links-title">Profile</a></li>
      <li><a href="#links-title">Billing</a></li>
      <li><a href="#links-title">Sign out</a></li>
    </ul>
  </nav>
</div>

Attributes

Attribute or valueWhereEffect
<dui-menu>wraps the button and its popover
popovertarget="menu-id"the <button> (native)
popover data-popoverthe menu element
<button> or <a href> childrenthe actions; <hr> separates groups

Added by the component: aria-haspopup, aria-expanded, role="menu", role="menuitem", tabindex="-1".

Keyboard

KeyAction
Enter / Space / Down Arrowon the button, opens the menu and focuses the first item
Up Arrowon the button, opens the menu and focuses the last item
Down Arrow / Up Arrownext or previous item, wrapping
Home / Endfirst or last item
A letternext item whose label starts with it
Enter / Spaceactivates the item and closes the menu
Esccloses the menu and returns focus to the button
Tabcloses the menu and moves on

Accessibility

  • <dui-menu> adds the ARIA and arrow keys. Without JavaScript, every action is a Tab stop.
  • For links to other pages, use a disclosure: role="menu" means arrow keys and no Tab stops (APG note).

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

Search