Dropdown menu

A button-triggered list of actions. One size, 32px rows with 14px text and icons; rows grow to 40px on touch.

Usage

pnpm dlx shadcn@latest add dropdown-menu

Then replace components/ui/dropdown-menu.tsx and add menu-styles.ts from the Matrix versions. The menu card, rows, labels and dividers come from menu-styles.ts, which Select shares, so a menu and a select's options always look the same. Menus animate with tw-animate-css, shadcn's standard.

import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';

<DropdownMenu>
  <DropdownMenuTrigger asChild>
    <Button variant="ghost" square aria-label="More options"><Ellipsis /></Button>
  </DropdownMenuTrigger>
  <DropdownMenuContent align="end">
    <DropdownMenuItem onSelect={rename}><Pencil /> Rename</DropdownMenuItem>
    <DropdownMenuItem onSelect={duplicate}><Copy /> Duplicate</DropdownMenuItem>
    <DropdownMenuSeparator />
    <DropdownMenuItem variant="destructive" onSelect={remove}><Trash2 /> Delete</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

A menu is for actions. To pick a value in a form, use a Select.

At a glance

An open menuStatic picture of every row type

Rows highlight in neutral on hover or with the arrow keys. The selected option shows a check at the end of the row. Delete is the only coral row.

Variants

Action menuIcon button, actions with icons
Account menuAvatar trigger, label, groups
With shortcutsRight-aligned hints
Multi-selectChecks, stays open
Single choiceOne option, picks and closes
With submenu

Behavior

The keyboard is built in

Enter, Space or ArrowDown opens the menu; arrows move, typing jumps to a matching row, Escape closes and returns focus to the trigger.

Highlight, not a focus ring

Rows highlight in neutral on hover and with the arrow keys. The gold ring stays on the trigger, so a menu never fills with rings.

Rows don't wrap

Labels stay on one line. Keep them short (verb + noun); the menu grows to fit, up to the screen edge.

Touch grows the rows

On a touch screen rows grow from 32px to 40px, automatically.

API reference

Prop

Type

Guidelines

  • Open menus from a button: an icon button (⋯) for row or card actions, a labelled button for a toolbar.
  • Write rows as verb + noun ("Rename agent"); order them by how often they're used, with destructive actions last, after a divider.
  • Use a divider only before destructive rows or between labelled groups. Ordinary actions like Archive or Share don't get their own divider.
  • Give every row an icon or none; don't mix within a group.
  • Don't use a menu to pick a value in a form; use a Select.
  • Don't nest more than one submenu deep.