Dropdown menu
Actions on a thing, opened from a control.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
Actions on a thing, opened from a control.
Import
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuGroup, DropdownMenuContent, DropdownMenuItem, DropdownMenuShortcut, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent } from "@ir/ui";Watch out
- Two inconsistencies in the file, neither acted on:
Variants
| Axis | Options | Default |
|---|---|---|
variant | default · destructive | default |
Do and don't
Use Select for values; menus are for actions.
Don't — Use a dropdown menu to choose a value for a field.
A menu does something when you pick a row. A select stores what you picked — different promises, different keyboard behaviour.
Leave focus to do the work.
Don't — Add a hover state to a menu row.
Radix moves DOM focus on pointer-over as well as arrow keys, so one state covers both. A second one double-lights the row.
Put them last, behind a separator.
Don't — Scatter destructive actions through the list.
The pointer travels down the list. A delete sitting mid-list is one slip away from the row above it.
Only show keys that actually work from that screen.
Don't — Show a shortcut the app has not bound.
A printed shortcut is a promise. People try it once, and stop trusting the menu when it does nothing.
Flatten, or open a dialog for the complicated case.
Don't — Nest submenus more than one deep.
Each level is another hover corridor to keep the pointer inside, and each one loses people.
Accessibility
- Radix supplies the menu and menuitem roles, typeahead and arrow-key movement. Do not add roles of your own.
- Disabled items use data-[disabled] rather than the disabled attribute — they keep pointer-events-none and 50% opacity but stay in the menu, so their existence is still discoverable.
- Hover and keyboard focus are one state here, because Radix drives both through data-highlighted. There is no separate :focus-visible treatment to add.
- The submenu chevron is aria-hidden; the item's text is its name.
- CheckboxItem and RadioItem are deliberately not wrapped — use Radix's directly when a menu needs them, and they bring their own menuitemcheckbox and menuitemradio semantics.
Where it is drawn
Figma — structure from figma, measurements from figma.