Action menu that opens from a button, for account controls, row actions, and overflow commands.
Description
DropdownMenu is a compound popover menu built on Radix's DropdownMenu primitive. It composes DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem (with optional DropdownMenuGroup, DropdownMenuLabel, and DropdownMenuSeparator) into a portalled, keyboard-driven menu. size is set on the root and cascades through context to every item and label.
Reach for it when a button needs to fan out into a short list of commands or one-of-many switches: account menus, row actions, overflow ("...") menus on cards, sort and filter pickers, "open in" link lists. It works equally well attached to a labeled icon button, an avatar, or a plain text trigger.
Don't use it as a form control. For binding a single value to a form field, use Select. For right-click on a region, use ContextMenu. For arbitrary popover content with no menu semantics, use Popover. For passive hover hints, use Tooltip.
Installation
Anatomy
Usage
Examples
Sizes
Three sizes (xs, sm, md) match the rest of the type and form scale. sm is the default. Set size on the root; trigger, content radius, item height, label, and icon size all scale from there.
With Icons
Drop an icon as the first child of DropdownMenuItem to render it as a leading affordance. The item handles its own gap and aligns the icon to the size scale.
Groups and Separator
Use DropdownMenuGroup to bundle related items, DropdownMenuLabel to head a group, and DropdownMenuSeparator to split sections. Groups are semantic only, the separator is what creates the visible break.
Selected
selected marks an item as the active value: text shifts to body weight and a primary-colored check is rendered at the trailing edge. Use showCheck when you want the trailing check glyph without the selected styling (e.g. for items toggleable independently).
With Avatar
Common account-menu pattern: a pill-shaped, icon-only Button holds an Avatar as the trigger, and align="end" keeps the menu pinned to the trigger's right edge.
As Links
Pass asChild on DropdownMenuItem to render its underlying element as an <a> (or a router Link). The icon, padding, and highlight styles still apply to the link child.
Accessibility
DropdownMenu inherits Radix's menu keyboard model. The trigger is a single tab stop. Once the menu opens, arrow keys move focus between items, type-ahead jumps to a matching item, and Esc returns focus to the trigger.
ARIA notes:
- Radix wires
role="menu"on the content,role="menuitem"on each item, andaria-haspopup/aria-expandedon the trigger. The portal handles focus trapping while the menu is open. selectedonDropdownMenuItemis a visual cue (data-selected+ check icon), not a true checkbox role. For toggleable boolean items with proper semantics, use Radix'sDropdownMenu.CheckboxItemorDropdownMenu.RadioItemdirectly.- Disabled items receive
data-disabledand are skipped by keyboard navigation. Always give icon-only triggers anaria-label. - For portal, focus, and animation behavior beyond what's documented here, see Radix DropdownMenu.
Styling
Tailwind override: pass className to merge Tailwind classes on DropdownMenuContent or any sub-part (merged via cn()):
Data slots and attributes: the component sets these for CSS targeting:
data-slot="dropdown-menu"on the root,data-slot="dropdown-menu-trigger"on the trigger,data-slot="dropdown-menu-portal"on the portal,data-slot="dropdown-menu-content"on the popover,data-slot="dropdown-menu-group"on each group,data-slot="dropdown-menu-label"on labels,data-slot="dropdown-menu-item"on items,data-slot="dropdown-menu-separator"on separators.data-selectedon the item when theselectedprop is true.- Radix-managed:
data-state="open" | "closed"on trigger and content,data-side="top" | "right" | "bottom" | "left"anddata-align="start" | "center" | "end"on content,data-highlightedanddata-disabledon each item.
Target a state in CSS:
Related Components
- Select: form-value picker bound to a
Field. Use it when the chosen value is what the form submits. - ContextMenu: same menu shape, triggered by right-click (or long-press) on a region.
- Popover: arbitrary content with no menu semantics or roving focus.
- Tooltip: passive hover description, never a place to put actions.
API Reference
DropdownMenu
Wraps Radix's DropdownMenu.Root and provides the DropdownMenuContext that sub-parts read for size. Extends React.ComponentProps<typeof DropdownMenuPrimitive.Root>, so all Radix root props (open, defaultOpen, onOpenChange, modal, dir) pass through.
Props
Variants
DropdownMenuTrigger
Wraps Radix's DropdownMenu.Trigger. Extends Radix DropdownMenu.Trigger props (asChild, plus any standard button attributes).
Props
DropdownMenuPortal
Wraps Radix's DropdownMenu.Portal. Extends React.ComponentProps<typeof DropdownMenuPrimitive.Portal>. Rarely used directly because DropdownMenuContent already portals itself.
Props
DropdownMenuContent
Wraps Radix's DropdownMenu.Content rendered inside DropdownMenu.Portal. Extends React.ComponentProps<typeof DropdownMenuPrimitive.Content>, so all Radix content props pass through.
Props
DropdownMenuGroup
Wraps Radix's DropdownMenu.Group. Use it to bundle related items, optionally with a DropdownMenuLabel header.
Props
DropdownMenuLabel
Wraps Radix's DropdownMenu.Label. Sized by the surrounding DropdownMenuContext. Renders a non-interactive heading above a group of items.
Props
DropdownMenuItem
Wraps Radix's DropdownMenu.Item. Extends React.ComponentProps<typeof DropdownMenuPrimitive.Item>, so onSelect, disabled, textValue, and asChild pass through. The first child can be an icon; the remaining children become the label.
Props
DropdownMenuSeparator
Wraps the shared Separator component. A thin divider for splitting groups inside the content.