Overlays
Dropdown menu
A focused list of actions on a trigger.
Usage
Compose DropdownMenu, a trigger and the content. Items take an icon and a shortcut; variant="destructive" colours a risky action. Submenus open to the side on hover or ArrowRight.
When to use
- A short list of actions that belong to one control: an account, a row, a toolbar overflow.
- Toggles and single-choice options that apply straight away.
Not for: choosing a value for a form field (use a select), navigation between pages (use links or tabs), or rich content (use a popover).
Row actions
An icon-only trigger needs an aria-label. Align the menu to the trigger’s edge with placement="bottom-end"; disabled items are skipped by the arrow keys.
Checkbox items that keep it open
Choosing an item closes the menu. For settings people adjust several at once, call event.preventDefault() in onSelect.
API
DropdownMenu
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | — | Controlled open state. |
| defaultOpen | boolean | false | Initial state when uncontrolled. |
| onOpenChange | (open: boolean) => void | — | Called when the menu asks to open or close. |
DropdownMenuContent
| Prop | Type | Default | Description |
|---|---|---|---|
| placement | 'top' | 'right' | 'bottom' | 'left' (+ '-start' | '-end') | 'bottom-start' | Preferred side and alignment. |
| align | 'start' | 'center' | 'end' | — | Overrides the alignment of placement. |
| offset | number | 6 | Gap to the trigger, px. |
| matchWidth | boolean | false | At least as wide as the trigger. |
DropdownMenuItem
| Prop | Type | Default | Description |
|---|---|---|---|
| icon | ReactNode | — | Leading 16px icon. |
| shortcut | ReactNode | — | Shortcut hint on the right. |
| variant | 'default' | 'destructive' | 'default' | Destructive colours the item red. |
| disabled | boolean | — | Skipped by the arrow keys, cannot be chosen. |
| inset | boolean | — | Indent to line up with checkbox and radio items. |
| onSelect | (event: Event) => void | — | Called when chosen. event.preventDefault() keeps the menu open. |
| asChild | boolean | — | Render your own element, e.g. a link. |
Checkbox and radio items
| Prop | Type | Default | Description |
|---|---|---|---|
| DropdownMenuCheckboxItem checked | boolean | — | Controlled state; also defaultChecked and onCheckedChange. |
| DropdownMenuRadioGroup value | string | — | Controlled value; also defaultValue and onValueChange. |
| DropdownMenuRadioItem value | string | — | The value this item selects. |
Also: DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuGroup, DropdownMenuSub, DropdownMenuSubTrigger and DropdownMenuSubContent (placement defaults to right-start).
Keyboard
| Key | Action |
|---|---|
| Enter / Space / ↓ | On the trigger: opens the menu with the first item focused. |
| ↑ | On the trigger: opens the menu with the last item focused. |
| ↓ / ↑ | Next / previous item (wraps around). |
| Home / End | First / last item. |
| A–Z | Typeahead: jumps to the item that starts with what you type. |
| Enter / Space | Chooses the item. |
| → | On a submenu item: opens it and focuses its first item. |
| ← / Esc | In a submenu: closes it. Esc in the main menu closes it and returns focus to the trigger. |
| Tab | Closes the menu. |
Accessibility
- Follows the WAI-ARIA menu button pattern: role="menu" with menuitem, menuitemcheckbox and menuitemradio items.
- The trigger has aria-haspopup="menu", aria-expanded and aria-controls; the menu is labelled by the trigger.
- Opened with the keyboard, focus lands on an item; opened with the pointer, on the menu itself. The highlight follows the pointer and the keyboard.
- Focus returns to the trigger on close, except after a click outside.
Motion
- Open: pops from the trigger side, scale .96, 4px travel (150ms, ease-out).
- Close: 160ms fade. Submenus use the same pop from their own side.
- Reduced motion: it appears and disappears without movement.