Skip to main content

Dropdown Menu

Displays a menu to the user — such as a set of actions or functions — triggered by a button.

import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
} from "@/components/ui/dropdown-menu"

<DropdownMenu>
<DropdownMenuTrigger asChild>
<button>Open Menu</button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuLabel>Section Title</DropdownMenuLabel>
<DropdownMenuItem>
<span>Item</span>
<div className="ml-auto flex flex-col items-end">
<span className="font-semibold">$0.01</span>
<span className="text-xs text-success">24.9%</span>
</div>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>
<span>Item</span>
<div className="ml-auto flex flex-col items-end">
<span className="font-semibold">$0.01</span>
<span className="text-xs text-success">24.9%</span>
</div>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>

API Reference

PropTypeDefaultDescription
modalbooleantrueWhether the dropdown menu is modal (blocks outside interaction)
openbooleanControlled open state
defaultOpenbooleanUncontrolled default open state
onOpenChange(open: boolean) => voidCallback when open state changes

The button that opens the dropdown menu.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child element instead of rendering a default button

The popup container for dropdown menu items. Renders in a portal.

PropTypeDefaultDescription
sideOffsetnumber4Distance from the trigger element
align"start" | "center" | "end""center"Alignment relative to the trigger
avoidCollisionsbooleantrueWhether to flip side when hitting viewport boundary

An interactive item within the menu.

PropTypeDefaultDescription
disabledbooleanfalsePrevents interaction and applies dimmed styling
insetbooleanfalseAdds left padding to align with items that have indicators
onSelect(event: Event) => voidCallback when the item is selected

A menu item that can be toggled on or off with a checkmark indicator.

PropTypeDefaultDescription
checkedbooleanControlled checked state
onCheckedChange(checked: boolean) => voidCallback when checked state changes

A group of items where only one can be selected at a time, indicated by a filled circle.

PropTypeDefaultDescription
valuestringThe value of the selected radio item
onValueChange(value: string) => voidCallback when the selected value changes

Renders a nested submenu with a trigger item that shows a chevron indicator.

A non-interactive label for grouping menu items. Renders in uppercase small text.

A horizontal divider between groups of items.

A styled span for displaying keyboard shortcut hints alongside a menu item.

Accessibility

The Dropdown Menu component follows WAI-ARIA menu patterns:

  • Opens on click of the trigger button
  • Supports keyboard navigation (Arrow keys to move between items, Enter/Space to select)
  • Escape key closes the menu
  • Submenus open with ArrowRight and close with ArrowLeft
  • Focus is trapped within the menu while open
  • Disabled items are skipped during keyboard navigation
  • Checkbox and radio items announce their state to screen readers