Components, Overlays
Menu and popover
A list of actions that opens from a button, plus a popover for other content on the same layer.
Visibility
Anyone with the link can view this Output.
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:
popoversurface, 1pxborder,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 isaccent. - Selected item: the
accentsurface. - Danger item (
tone="danger"):destructive-texttext and adestructive-softhover surface. - Hint (
hint): 12pxmuted-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 IconButtonxswith MoreHorizontal.- The
aria-labelof 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-disabledand give the reason intitle. - Don’t put a menu inside a menu.