Dropdown Menu
Open a compact list of actions and options from a trigger.
Preview
Use a dropdown menu to put related actions behind one button. Labels and separators help people scan longer menus.
Installation
pnpm dlx shadcn@latest add https://migoy.stanleyaf.com/r/dropdown-menu.jsonUses Base UI, Lucide icons, the existing cn utility, and semantic theme tokens. The preview composes the separately installable Button using render.
Usage
- Use
DropdownMenuItemwithonClickfor commands andDropdownMenuLinkItemwithhreffor navigation. - Use checkbox items for independent options and a radio group for mutually exclusive options. Control them with
checkedandonCheckedChange, orvalueandonValueChangeon the radio group. - Use
DropdownMenuGroupwithDropdownMenuLabelfor named sections. Use separators between sets of items. - Content is portaled and positioned automatically. Set
align,side, orsideOffsetwhen needed.
Composition
DropdownMenu
├── DropdownMenuTrigger
└── DropdownMenuContent
├── DropdownMenuGroup
│ ├── DropdownMenuLabel
│ └── DropdownMenuItem
│ └── DropdownMenuShortcut
├── DropdownMenuSeparator
├── DropdownMenuCheckboxItem
├── DropdownMenuRadioGroup
│ └── DropdownMenuRadioItem
└── DropdownMenuSub
├── DropdownMenuSubTrigger
└── DropdownMenuSubContent
└── DropdownMenuLinkItemStart with a trigger, content, and one or more items. Add groups and separators when the menu has distinct sections. Checkbox items can stand on their own, while radio items belong inside a radio group. Each submenu pairs its own trigger with its own content. A shortcut hint goes inside the item it describes.
Icons and links
Pair familiar icons with visible labels. Use link items when the destination is a page.
Submenus
Use a submenu for a related set of secondary actions. Keep frequently used actions in the first menu.
Shortcuts
Use DropdownMenuShortcut to show a key combination beside its action. The hints in this example are illustrative. Wire up the key combinations in your app and show the appropriate keys for the user's platform.
Checkbox items
Use checkbox items when each option can change independently. These choices update the preview menu state.
Radio items
Use a radio group when the options are mutually exclusive.
Destructive actions
Use the destructive variant for actions that remove data. Ask for confirmation when the action is hard to undo.
Keyboard and accessibility
Give the trigger a visible label or an accessible name. Open it with Enter or Space, move through items with the arrow keys, and press Enter to activate the focused item. Escape closes the current menu and returns focus to its trigger. Keep submenu labels specific so people can tell what they’ll find inside.
Based on shadcn Dropdown Menu and Base UI Menu.