Redpanda UIRedpanda UI

Dropdown Menu

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

Made by imskyleen

Installation

Loading component...

When to use

Use this decision tree to determine when to use the Dropdown Menu component:

Usage

<DropdownMenu>
  <DropdownMenuTrigger>Open Dropdown Menu</DropdownMenuTrigger>
  <DropdownMenuContent>
    <DropdownMenuItem>Item 1</DropdownMenuItem>
    <DropdownMenuItem>Item 2</DropdownMenuItem>
    <DropdownMenuItem>Item 3</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Examples

Checkboxes

Loading component...

Radio Group

Loading component...
Loading component...

Labeled sections

Loading component...

Keyboard shortcuts

Loading component...
Loading component...

Open a Dialog from an item

Loading component...
Loading component...

Avatar user menu

Loading component...

Animated viewport

Loading component...

Open on hover

Loading component...

Props

Animate UI Props

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Keyboard interactions

KeyAction
Enter / Space / ArrowDown on DropdownMenuTriggerOpens the menu and focuses the first item.
ArrowUp / ArrowDownMoves between items. Wraps at the edges.
ArrowLeft / ArrowRightOpens / closes submenus.
Home / EndJumps to first / last item.
Enter / SpaceActivates the focused item.
EscapeCloses the menu and restores focus to the trigger.
Typing a characterMoves focus to the next item whose label starts with that character (typeahead).

Accessibility

  • DropdownMenuTrigger exposes aria-haspopup="menu" and aria-expanded; the menu itself is role="menu" with role="menuitem" / menuitemcheckbox / menuitemradio on its children.
  • Focus is fully roving inside the menu — no tabIndex={0} needed on items.
  • Destructive items should set variant="destructive" (visual) and, if the action is irreversible, open an AlertDialog for confirmation rather than firing immediately.
  • The trigger must be a button (or another interactive element via asChild); static <div> triggers lose keyboard activation.

Controlled vs uncontrolled

Uncontrolled — typical case:

<DropdownMenu>
  <DropdownMenuTrigger asChild><Button onClick={() => undefined}>Actions</Button></DropdownMenuTrigger>
  <DropdownMenuContent>
    <DropdownMenuItem onClick={onEdit}>Edit</DropdownMenuItem>
    <DropdownMenuItem onClick={onDelete}>Delete</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Controlled — drive open from parent state (e.g. to open programmatically from a keyboard shortcut):

const [open, setOpen] = useState(false);

<DropdownMenu open={open} onOpenChange={setOpen}>
  <DropdownMenuTrigger asChild><Button onClick={() => undefined}>Actions</Button></DropdownMenuTrigger>
  <DropdownMenuContent>{/* ... */}</DropdownMenuContent>
</DropdownMenu>

Credits

Recent changes

  • patchv1.2.0Pin shipped dependency floors to the version we develop against. Registry items now declare ranges like `^5.1.9` (the actual installed version) instead of collapsing to `^5.0.0`, so consumers start on the known-tested b…#133
  • minorv1.1.0Theme docs refresh, readability pass on semantic foregrounds, and consumer-facing Base UI regression fixes.#121
  • minorv1.1.0Bulk install experience and Dialog polish.#119
  • minorv1.0.0Post-Base-UI polish. Public API unchanged.#116
  • majorv1.0.0Migrate every Radix-based primitive to `@base-ui/react@^1.4.0` (Base UI).#114
See full history →
Built by malinskibeniamin. The source code is available on GitHub.

On this page