Skip to content

Dropdown Menu

Download .md

A dropdown menu lists actions behind one button, such as the actions of a table row.

  • Use it when a row or card has more actions than fit as buttons.
  • Put the most used action first and destructive actions last, after a separator.
  • Use a Select to pick a value, not a menu.
React
Vue
DoPut a destructive item last, after a separator.
Don'tDon't put a destructive item first, where a quick click lands.
1234
  1. 1Trigger button
  2. 2Menu on elevation-lg
  3. 3Highlighted item
  4. 4Destructive item, last and after a separator

A trigger, usually a ghost icon button, and a popup on popover with a border, radius-lg and shadow-lg. Items use radius-md and highlight with accent.

Items can be destructive (text-destructive), checkboxes, radio items or sub-menus.

React Vue Flutter Type Default Use
DropdownMenuTrigger render DropdownMenuTrigger as-child child with controller.toggle element button The control that opens it.
DropdownMenuItem variant DropdownMenuItem variant none default | destructive default Marks a destructive action.
onClick on an item @select on an item onPressed on ShadContextMenuItem function none Runs the action.
import { MoreHorizontalIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
export default function DropdownMenuDemo() {
return (
<DropdownMenu>
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="Aksi" />}>
<MoreHorizontalIcon />
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>Lihat</DropdownMenuItem>
<DropdownMenuItem>Ubah</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive">Hapus</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/dropdown-menu.json
  • Renders role="menu" and menuitem; arrow keys move, Enter runs, Escape closes.
  • Icon-only triggers need an aria-label.