Duolith docs

Menu

A list of actions that opens next to its trigger, with icons, destructive and disabled items, and dividers.

Stability: experimental

Props

PropTypeDefaultMeans
labelstringThe menu's accessible name.
items{ label?: string; icon?: string; destructive?: boolean; disabled?: boolean; divider?: boolean; onSelect?: () => void }[]The items in order. An item with divider: true is a line between groups.
openbooleanbindable(false)Whether the menu shows. The trigger piece toggles it; choosing an item, Escape, Tab or a press outside clears it.
placement"bottom-start" | "bottom-end" | "top-start" | "top-end"bottom-startWhere the menu sits next to its trigger. It flips and shifts to stay in the window.

Pieces

PieceMeans
triggerThe control that opens the menu, such as an IconButton with the more icon.

States

StateLooks like
openA surface panel, at least 200px wide, with a border, a large radius and shadow; items 44px tall.
focused itemThe raised background.
destructive itemThe label and icon in the danger colour.
disabled item45% opacity; skipped by the keys.
openingFades and grows in, in 120 ms; at once with reduced motion.

Accessibility

rolemenu of menuitem buttons, with separators
nameThe label prop (aria-label); each item by its text.
focusOn open, focus moves to the first item (the last when opened with ArrowUp). On close, focus returns to the trigger.
keyboardArrowDown and ArrowUp move between items, wrapping; Home and End go to the first and last; typing letters goes to the next item that starts with them; Enter or Space chooses; Escape or Tab closes. ArrowDown or ArrowUp on the closed trigger opens it.
notesThe trigger carries aria-haspopup="menu", aria-expanded and aria-controls.

Theme tokens

color.surface color.ink color.border color.raised color.muted color.danger shadow.lg radius.lg radius.sm space.1 space.2 space.3 text.body

Example

<Menu label="Post actions" items={actions}><piece name="trigger"><IconButton icon="more" label="More" /></piece></Menu>