Dropdown menu
Actions behind a button: items with shortcuts, checkbox and radio items, groups, submenus and a destructive item.
Installation
Or with the shadcn CLI, from the registry:
Usage
Checkbox and radio items
DropdownMenuCheckboxItem (checked, onCheckedChange) and DropdownMenuRadioGroup with DropdownMenuRadioItem
(value, onValueChange) keep the menu open and show a check.
Submenus
DropdownMenuSub around a DropdownMenuSubTrigger and a DropdownMenuSubContent.
Villages
A popover surface with the village's highlight: Iwa inverts the highlighted item.
Accessibility
- A
menuofmenuitems (menuitemcheckbox,menuitemradio), opened by a button witharia-haspopup. - Arrow keys move the highlight, typing jumps to an item, Enter activates, → opens a submenu, Esc closes.
- Shortcuts are only shown: wire the key yourself, and keep it in the item's text so it is read.
API reference
The parts of Base UI's Menu, styled:
| Part | Notes |
|---|---|
DropdownMenu | open, defaultOpen, onOpenChange, modal |
DropdownMenuTrigger | render to use a Button; openOnHover |
DropdownMenuContent | portal and popup; side, sideOffset (6), align ("start") |
DropdownMenuItem | variant: "default" | "destructive", inset, onClick, closeOnClick |
DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem | checked items |
DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut | grouping and hints |
DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent | submenus |