pnpm dlx shadcn@latest add "https://godui.design/r/dropdown-menu.json"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
<DropdownMenu>
<DropdownMenuTrigger>Open</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem>Profile</DropdownMenuItem>
<DropdownMenuItem>Billing</DropdownMenuItem>
<DropdownMenuItem>Team</DropdownMenuItem>
<DropdownMenuItem>Subscription</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Built on Radix Dropdown Menu Root; accepts all its props.
| Prop | Type | Default | Description |
|---|
open | boolean | none | Whether the menu is open. Use when controlled. |
defaultOpen | boolean | false | Whether the menu starts open. |
onOpenChange | (open: boolean) => void | none | Called when the menu opens or closes. |
modal | boolean | true | Block interaction with the rest of the page while open. |
dir | "ltr" | "rtl" | none | Reading direction. Inherits from DirectionProvider when unset. |
The button that toggles the menu. Built on Radix Dropdown Menu Trigger; accepts all its props.
| Prop | Type | Default | Description |
|---|
asChild | boolean | false | Render the child element instead, merging props. |
The animated menu, portaled and positioned against the trigger. Built on Radix Dropdown Menu Content; accepts all its props.
| Prop | Type | Default | Description |
|---|
side | "top" | "right" | "bottom" | "left" | "bottom" | Side of the trigger to open on. |
sideOffset | number | 4 | Distance from the trigger in pixels. |
align | "start" | "center" | "end" | "center" | Alignment against the trigger. |
alignOffset | number | 0 | Offset from the alignment edge in pixels. |
avoidCollisions | boolean | true | Flip and shift to stay inside the viewport. |
collisionPadding | number | Partial<Record<"top" | "right" | "bottom" | "left", number>> | 0 | Distance from the viewport edges for collision detection. |
loop | boolean | false | Wrap keyboard focus at the ends. |
Built on Radix Dropdown Menu Item; accepts all its props.
| Prop | Type | Default | Description |
|---|
variant | "default" | "destructive" | "default" | destructive colors the item for dangerous actions. |
inset | boolean | none | Add left padding to line up with items that have an indicator. |
onSelect | (event: Event) => void | none | Called when the item is chosen. Call event.preventDefault() to keep the menu open. |
disabled | boolean | false | Make the item unselectable. |
textValue | string | none | Text used for typeahead when the content isn't plain text. |
asChild | boolean | false | Render the child element instead, merging props. |
An item with a check that pops in when it's toggled. Built on Radix Dropdown Menu CheckboxItem; accepts all its props.
| Prop | Type | Default | Description |
|---|
checked | boolean | "indeterminate" | none | Checked state. |
onCheckedChange | (checked: boolean) => void | none | Called when the item is toggled. |
disabled | boolean | false | Make the item unselectable. |
Built on Radix Dropdown Menu RadioGroup; accepts all its props.
| Prop | Type | Default | Description |
|---|
value | string | none | Value of the selected item. |
onValueChange | (value: string) => void | none | Called when the selection changes. |
An item with a dot that pops in when it's selected. Built on Radix Dropdown Menu RadioItem; accepts all its props.
| Prop | Type | Default | Description |
|---|
value | string | none | Value this item selects. Required. |
disabled | boolean | false | Make the item unselectable. |
Built on Radix Dropdown Menu Label; accepts all its props.
| Prop | Type | Default | Description |
|---|
inset | boolean | none | Add left padding to line up with items that have an indicator. |
Built on Radix Dropdown Menu Sub; accepts all its props.
| Prop | Type | Default | Description |
|---|
open | boolean | none | Whether the sub-menu is open. Use when controlled. |
defaultOpen | boolean | none | Whether the sub-menu starts open. |
onOpenChange | (open: boolean) => void | none | Called when the sub-menu opens or closes. |
The item that opens a sub-menu, with a chevron. Built on Radix Dropdown Menu SubTrigger; accepts all its props.
| Prop | Type | Default | Description |
|---|
inset | boolean | none | Add left padding to line up with items that have an indicator. |
disabled | boolean | false | Make the trigger unselectable. |
The animated sub-menu. It grows from its trigger item. Built on Radix Dropdown Menu SubContent; accepts all its props (sideOffset, alignOffset, avoidCollisions, loop).
Built on Radix Group and Portal; each accepts all its props. DropdownMenuContent already renders its own portal.
DropdownMenuSeparator is built on Radix Dropdown Menu Separator. DropdownMenuShortcut renders a native <span> for a keyboard hint. Both accept all their props.
Props match shadcn/ui Dropdown Menu.