Dropdown Menu presents actions in a compact popover. It opens from a button and closes when an action is chosen or the user clicks outside. Arrow keys, Home and End move between actions. Escape closes the menu and returns focus to the trigger.
Browser support
Feature
Baseline
Your browser
Popover
Displays content in the browser top layer.
Your browser:
Anchor positioning
Positions content by its trigger; JavaScript positions it when anchors are unavailable.
Your browser:
@starting-style
Animates entry when supported; otherwise content appears immediately.
Your browser:
Preview
Installation
Usage
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@/components/ui/dropdown-menu"
<DropdownMenu>
<DropdownMenuTrigger asChild><button>Actions</button></DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onSelect={() => console.log("Edit")}>Edit</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>Examples
Position
The menu opens on the chosen side of the trigger. When there is not enough room, it flips to the opposite side on its own.
<DropdownMenuContent side="top">...</DropdownMenuContent>
<DropdownMenuContent side="bottom" align="end">...</DropdownMenuContent>Language switcher
Menu items can be links. Ready-made version: Language Switcher
<DropdownMenu>
<DropdownMenuTrigger aria-label="Language">EN</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<a role="menuitem" tabIndex={-1} href="/" aria-current="true">English</a>
<a role="menuitem" tabIndex={-1} href="/ru">Русский</a>
</DropdownMenuContent>
</DropdownMenu>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| side | "top" | "bottom" | "left" | "right" | "bottom" | Preferred side of the trigger. Flips to the opposite side when there is no room. |
| align | "start" | "center" | "end" | "center" | Alignment along the trigger. |
| sideOffset | number | 4 | Distance from the trigger in pixels. |
| asChild | boolean | false | Use the child as the trigger. |
| onSelect | (event) => void | — | Runs on selection; preventDefault keeps the menu open. |
| disabled | boolean | false | Disable this action. |