Skip to content
weftGitHub

Menu

A short list of actions that opens from a button.

SourcePackage @weft-js/warp

Preview

tsx
import { Menu } from '@weft-js/warp'export function Basic() {  return (    <Menu label="Actions" items={[      { label: 'Rename', icon: 'pencil', shortcut: '⌘R' },      { label: 'Duplicate', icon: 'copy', shortcut: '⌘D' },      { separator: true },      { label: 'Delete', icon: 'trash', tone: 'critical' },    ]} />  )}

Installation

npm install @weft-js/warp

Usage

tsx
import { Menu } from '@weft-js/warp'<Menu label="Actions" items={[  { label: 'Rename', icon: 'pencil', shortcut: '⌘R' },  { label: 'Duplicate', icon: 'copy', shortcut: '⌘D' },  { separator: true },  { label: 'Delete', icon: 'trash', tone: 'critical' },]} />

Placement

Use side to pick where it opens.

Alignment

Use align to line it up with the button.

Groups

A group entry names what follows.

Trigger styles

trigger takes any Button prop.

A row's actions

Use items to list a row's actions, and trigger to make the button quiet enough to sit in a row.

When to use

Use it for

  • Several actions on one thing, and not much room

Reach for something else

Accessibility

Enter
Opens, or picks the highlighted item
↑↓
Moves through the items
HomeEnd
Jumps to the first or last
Esc
Closes and returns focus
Aletter
Jumps to the next item starting with it

API Reference

PropTypeDefaultDescription
labelunknown—The trigger's text.
itemsMenuEntry[]—The entries: an action, { separator: true } or { group }.
triggerButtonProps—Button props for the trigger.
sideSide'bottom'Which side it opens on.
alignAlign'start'How it lines up with the trigger.

Parts

Every element carries a stable name, so you can style it from your own CSS: [data-scope="menu"] [data-part="content"]

contentshuttleseparatorgroup-labelitem

RelatedButtonPopoverCommand palette