Dropdown Menu
Displays a menu to the user triggered by a button.
Installation
bash
npx shadcn@latest add dropdown-menuImport
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup,} from "@/components/ui/dropdown-menu"Basic
With shortcuts
Props
DropdownMenu
PROPTYPEDEFAULTDESCRIPTION
openboolean—Controlled open stateonOpenChange(open: boolean) => void—Called when open state changesmodalbooleantrueWhether to render as a modalDropdownMenuContent
PROPTYPEDEFAULTDESCRIPTION
align"start" | "center" | "end""center"Alignment relative to triggersidestring—Preferred side of the triggersideOffsetnumber—Offset from the triggerloopbooleanfalseWhether keyboard navigation loopsDropdownMenuCheckboxItem
PROPTYPEDEFAULTDESCRIPTION
checkedboolean—Controlled checked stateonCheckedChange(checked: boolean) => void—Called when checked state changesDropdownMenuRadioGroup
PROPTYPEDEFAULTDESCRIPTION
valuestring—Controlled selected valueonValueChange(val: string) => void—Called when value changesAccessibility
- Arrow keys navigate between items
- Enter/Space selects an item
- Escape closes the menu
- Type-ahead jumps to matching item