Skip to content

Menu

The WAI-ARIA menu button pattern: arrows move, Home and End jump, typing a letter jumps, Enter chooses and Escape gives focus back to the button. ArrowUp opens at the last item. Check items stay open; actions close first, so anything they open remembers the button. One pill springs between items whether focus moves by keyboard or pointer.

  • role=menu
  • Roving focus
  • Typeahead
  • Spring Physics
  • Popover API
Files
  • Brand guidelines.pdfPinned
  • Launch plan.md
  • Interview notes.md

Tab to a ⋯ button and press ArrowDown, then use the arrows, Home and End, or type a letter. Escape gives focus back to the button. Pin to top stays open; everything else closes.

    Usage

    Drop it in

    import
    import { Menu } from "@/app/lib/components/menu";
    example 1
    <Menu
      trigger={<IconButton aria-label="Project actions"><MoreHorizontal size={16} /></IconButton>}
      items={[
        { label: "Rename", shortcut: "R", onSelect: rename },
        { type: "separator" },
        { label: "Delete", tone: "danger", onSelect: remove },
      ]}
    />

    API

    Props

    PropTypeDefault
    trigger*

    The button that opens it. It gets aria-haspopup, aria-expanded and aria-controls.

    ReactElement—
    items*MenuItem[]—
    side

    Preferred side. It flips when there is no room. Default: "bottom"

    Side"bottom"
    align

    Alignment along the trigger. Default: "start"

    Align"start"
    offset

    Gap from the trigger in px. Default: 6

    number6
    positioning

    "auto" uses CSS anchor positioning where the browser has it, "js" always measures. Default: "auto"

    Positioning"auto"
    onOpenChange

    Called whenever it opens or closes.

    (open: boolean) => void—
    classNamestring""

    Read from the component's source at build time. * required.

    Accessibility

    Works with

    Cursor
    Reacts to where the pointer is, not just whether it's over the element.
    Touch
    Follows your finger while it's down, then settles a moment after you lift.
    Keyboard
    Focus lights it up the way the cursor does. Every action has a key.
    Reduced motion
    Nothing moves or springs. Colour still answers, without drifting.