Skip to content
Theme
endue.ai

Components, Overlays

Menu and popover

A list of actions that opens from a button, plus a popover for other content on the same layer.

Name in code Menu

A list of actions that opens when you press a button. Popover, which holds any content on the same layer, lives here too.

Appearance

  • Menu: popover surface, 1px border, shadow-md, 8px corner radius, 4px inner padding, minimum width 180px.
  • Item: 14px text, 8px by 12px padding, 4px corner radius. The icon is 16px in muted-foreground. The hover and focus surface is accent.
  • Selected item: the accent surface.
  • Danger item (tone="danger"): destructive-text text and a destructive-soft hover surface.
  • Hint (hint): 12px muted-foreground, at the right end.
  • Separator: 1px border, with 4px above and below.
  • Popover: the same surface with a 12px corner radius, 12px inner padding and role="dialog".

Every floating layer is a popover surface with a 1px border and shadow-md. The surface is neutral.

Keyboard

Opening with Enter, Space or ↓ moves focus to the first item. Opening with ↑ moves focus to the last item. ↑ and ↓ wrap around and skip disabled items. Esc closes the menu and returns focus to the trigger.

What you provide

  • trigger: usually an IconButton xs with MoreHorizontal.
  • The aria-label of the menu.
  • Item labels are verbs (“Rename”). A dangerous action goes last, after a separator.

Markup

<div role="menu" aria-label="Conversation menu" class="Menu_menu">
  <button type="button" role="menuitem" tabindex="-1" class="Menu_item">
    <span class="Menu_itemIcon" aria-hidden="true"><svg>…</svg></span>
    <span class="Menu_itemLabel">Rename</span>
    <span class="Menu_itemHint">F2</span>
  </button>
  <div role="separator" class="Menu_separator"></div>
  <button type="button" role="menuitem" tabindex="-1" class="Menu_item Menu_item--danger"><span class="Menu_itemLabel">Delete</span></button>
</div>

The menu starts hidden with position: fixed. In a static document, override it with position: static; visibility: visible to draw it.

Don’t

  • Don’t hide an item that cannot be chosen. Keep it with aria-disabled and give the reason in title.
  • Don’t put a menu inside a menu.