Dropdown Menu
A list of actions that opens from a button.
When to use
- Secondary actions for one object, behind a single trigger: rename, duplicate, or archive a source.
- Actions that don't fit in a toolbar or a table row.
When not to use
- Picking a value in a form: use Select or Combobox.
- Moving between pages of the app: use Navigation Menu or Sidebar.
- The main action of a view: show it as a Button.
- Searching a long list of actions: use Command.
Install
npx shadcn@latest add @clinia/dropdown-menuAnatomy
- 1Menu
data-slot="dropdown-menu-content"bg-popover · rounded-lg · p-1.5 - 2Group label
data-slot="dropdown-menu-label"text-xs · text-muted-foreground - 3Item
data-slot="dropdown-menu-item"text-sm · font-medium - 4Shortcut
data-slot="dropdown-menu-shortcut"text-xs · text-muted-foreground - 5Separator
data-slot="dropdown-menu-separator"bg-foreground/5 - 6Destructive item, last
[data-slot=dropdown-menu-item][data-variant=destructive]text-destructive
Clinia rules
- The highlighted item is
bg-foreground/4, the ink tint every hover and keyboard highlight uses, withtext-popover-foreground. destructiveis for delete, revoke, and remove: red text and a red tint. Not for archive or sign out, which lose nothing. Put destructive items last, after a separator.- Item labels are sentence case and start with a verb:
Rename source,Copy API key. DropdownMenuLabelnames a group intext-xs text-muted-foreground. It is never clickable.
Do and don't
States
Toggle the site theme to review both themes.
Accessibility
Built in
- Arrow keys move the highlight and loop at the ends. Escape closes the menu and returns focus to the trigger.
- Arrow Right opens a submenu and Arrow Left closes it.
- Checkbox and radio items announce their checked state.
Your responsibility
- Label an icon-only trigger with its object:
aria-label="Actions for Montreal clinic", not justMore. - Use
DropdownMenuCheckboxItemorDropdownMenuRadioItemfor state, never a check icon inside a plain item. - Keep menus to actions. Inputs and forms belong in a Popover or a Dialog.
How to test
- Press Tab to reach the trigger, then Enter or Space: the menu opens and focus moves into it.
- Press Arrow Down and Arrow Up: the highlight moves and wraps at the ends.
- Press Enter on an item: it runs and the menu closes.
- Open it again and press Escape: it closes and focus returns to the trigger.
- With a screen reader, the trigger announces its label, and each item is announced as a menu item.
API
DropdownMenuLabel
| Prop | Values | Default | Description |
|---|---|---|---|
| inset | boolean | – | Indents the label to line up with items that have an icon or an indicator. |
DropdownMenuItem
| Prop | Values | Default | Description |
|---|---|---|---|
| inset | boolean | – | Indents the item to line up with siblings that have an icon or an indicator. |
| variant | defaultdestructive | default |
|
DropdownMenuCheckboxItem
| Prop | Values | Default | Description |
|---|---|---|---|
| inset | boolean | – | Indents the item to line up with siblings that have an icon or an indicator. |
DropdownMenuRadioItem
| Prop | Values | Default | Description |
|---|---|---|---|
| inset | boolean | – | Indents the item to line up with siblings that have an icon or an indicator. |
DropdownMenuSubTrigger
| Prop | Values | Default | Description |
|---|---|---|---|
| inset | boolean | – | Indents the item to line up with siblings that have an icon or an indicator. |
All other props come from Base UI Menu.