Examples

Actions with sections

Preview
Example.tsx
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.

Preview
Example.tsx
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

Menu props
PropTypeDefault
childrenrequired
One 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.
Keyboard interactions
KeyAction
Enter / Space / ↓Open
↑ / ↓Move
EnterRun action
EscapeClose

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.