Actions
Menu
A list of actions opened from a button — the WAI-ARIA menu button pattern via React Aria, with sections, icons, descriptions, shortcuts and destructive items.
import { Menu } from '@reactloom/ui';Examples
Actions with sections
import { Button, Menu } from '@reactloom/ui';
import { Archive, ChevronDown, Copy, Pencil, Trash2 } from 'lucide-react';
import { useState } from 'react';
export default function Example() {
const [last, setLast] = useState<string>();
return (
<div style={{ display: 'grid', gap: 8, justifyItems: 'center' }}>
<Menu
onAction={setLast}
items={[
{ key: 'edit', label: 'Edit', icon: <Pencil />, shortcut: '⌘E' },
{ key: 'duplicate', label: 'Duplicate', icon: <Copy />, shortcut: '⌘D' },
{
type: 'section',
label: 'Danger zone',
items: [
{ key: 'archive', label: 'Archive', icon: <Archive /> },
{ key: 'delete', label: 'Delete', icon: <Trash2 />, tone: 'danger' },
],
},
]}
>
<Button variant="secondary" endIcon={<ChevronDown />}>Actions</Button>
</Menu>
<span role="status">{last ? `Chose “${last}”` : ''}</span>
</div>
);
}From an icon button
placement="bottom-end" aligns to the trigger’s end.
import { IconButton, Menu, Tooltip } from '@reactloom/ui';
import { MoreHorizontal } from 'lucide-react';
export default function Example() {
return (
<Menu
placement="bottom-end"
onAction={() => {}}
items={[
{ key: 'rename', label: 'Rename' },
{ key: 'move', label: 'Move to…', description: 'Choose another workspace' },
{ key: 'delete', label: 'Delete', tone: 'danger' },
]}
>
<IconButton icon={<MoreHorizontal />} label="More actions" variant="secondary" />
</Menu>
);
}API reference
| Prop | Type | Default |
|---|---|---|
childrenrequiredOne button element (Button, IconButton). | ReactElement | — |
itemsrequired{ key, label, icon?, shortcut?, description?, disabled?, tone? } or { type: "section", label?, items }. | (MenuAction | MenuSection)[] | — |
onActionrequired | (key: string) => void | — |
placement | OverlayPlacement | 'bottom-start' |
open / defaultOpen / onOpenChange | | — |
Accessibility
- Focus moves to the first item on open and returns to the trigger on close.
- Type-ahead, arrows, Home/End; disabled items are skipped.
- Shortcut hints are display-only — wire the shortcuts yourself.
| Key | Action |
|---|---|
| Enter / Space / ↓ | Open |
| ↑ / ↓ | Move |
| Enter | Run action |
| Escape | Close |
Usage guidelines
Do
- Group destructive actions in their own section.
Don’t
- Don’t use a menu for navigation links or for choosing a value — use Select.