Skip to content

Dropdown Menu ​

A list of actions or options opened from a button: row actions, an account menu, view settings. Use select to pick a form value, and command for a searchable list of commands.

Usage ​

vue
<DropdownMenu>
  <DropdownMenuTrigger as-child><Button>Actions</Button></DropdownMenuTrigger>
  <DropdownMenuContent>
    <DropdownMenuItem @select="rename">Rename</DropdownMenuItem>
    <DropdownMenuSeparator />
    <DropdownMenuItem variant="danger" @select="remove">Delete</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Props ​

PartPropTypeDefaultNotes
DropdownMenuopenbooleannonev-model:open
DropdownMenumodalbooleantruefalse keeps the page usable while open
DropdownMenuTriggerasChildbooleanfalseMerge onto the child, such as a Button
DropdownMenuTriggerasAsTag | ComponentnoneElement to render; Reka renders a button
DropdownMenuTriggerdisabledbooleanfalseWhen true, prevents the user from interacting with item
DropdownMenuContentalign'start' | 'center' | 'end''start'Against the trigger
DropdownMenuItemvariant'default' | 'danger''default'danger for destructive actions
DropdownMenuItemdisabledbooleanfalse
DropdownMenuCheckboxItemmodelValuebooleanfalsev-model
DropdownMenuCheckboxItemdisabledbooleanfalse
DropdownMenuRadioGroupmodelValuestringnonev-model; the chosen item's value
DropdownMenuRadioItemvaluestringnoneRequired
DropdownMenuRadioItemdisabledbooleanfalse
DropdownMenuSubopenbooleannonev-model:open
DropdownMenuSubTriggerdisabledbooleanfalse

Every part that renders an element takes class, merged last. DropdownMenu and DropdownMenuSub render no element of their own.

Name a DropdownMenuRadioGroup with one DropdownMenuLabel inside it, or with aria-label. The menu takes its direction from Reka's ConfigProvider (dir="rtl"), which also sets which arrow key opens a submenu; set it once at the app root of an RTL app. A long menu is capped at the room beside its trigger and scrolls; to cap it lower, pass a style with max-height (a max-h-* class can't beat the inline cap).

Slots ​

PartSlotContent
DropdownMenudefaultThe trigger and the content
DropdownMenuTriggerdefaultThe control that opens the menu
DropdownMenuContentdefaultItems, labels, separators and submenus
DropdownMenuItemdefaultThe action's name
DropdownMenuItemleadingAn icon before the name
DropdownMenuItemtrailingA shortcut hint or icon after the name
DropdownMenuCheckboxItemdefaultThe option's name
DropdownMenuRadioGroupdefaultRadio items
DropdownMenuRadioItemdefaultThe option's name
DropdownMenuLabeldefaultA heading for the items that follow
DropdownMenuSubdefaultThe sub trigger and the sub content
DropdownMenuSubTriggerdefaultThe submenu's name
DropdownMenuSubContentdefaultThe submenu's items

Events ​

PartEventPayloadWhen
DropdownMenuupdate:openboolean | undefinedThe menu opens or closes
DropdownMenuItemselectEventChosen by click, Enter or Space; preventDefault() keeps the menu open
DropdownMenuCheckboxItemupdate:modelValuebooleanToggled
DropdownMenuCheckboxItemselectEventChosen
DropdownMenuRadioGroupupdate:modelValuestring | undefinedAn item is chosen
DropdownMenuRadioItemselectEventChosen
DropdownMenuSubupdate:openboolean | undefinedThe submenu opens or closes

Tokens ​

None of its own. The menu is surface-raised with shadow-md, stacked at z-popover; the highlighted item is muted; a danger item uses danger-subtle-foreground, and danger-subtle when highlighted.

States ​

closed, open; item hover and keyboard highlight; disabled item; danger item; items with leading icons and trailing shortcuts; checkbox items on and off; radio items; labels and separators; an open submenu.

Keyboard ​

KeyAction
Enter, Space, ArrowDownOpen the menu on the trigger, first item highlighted
ArrowDown, ArrowUpMove between items, skipping disabled ones
Enter, SpaceChoose the highlighted item
ArrowRight (ArrowLeft in RTL)Open a submenu
ArrowLeft (ArrowRight in RTL)Close a submenu
LettersJump to the next item starting with them
EscapeClose; focus returns to the trigger

Accessibility ​

  • The content is role="menu"; items are menuitem, menuitemcheckbox and menuitemradio, with aria-checked on the last two.
  • The trigger has aria-haspopup="menu" and aria-expanded.
  • Leading icons and the check and radio marks are aria-hidden.
  • A trailing shortcut hint is text; it is read as part of the item's name.

Do ​

vue
<DropdownMenuItem @select="duplicate">
  <template #leading><Icon name="add" /></template>
  Duplicate
  <template #trailing>⌘D</template>
</DropdownMenuItem>

Do not ​

vue
<!-- A menu as a form field: use a select, so the value submits with the form. -->
<DropdownMenu>
  <DropdownMenuTrigger as-child><Button>{{ country }}</Button></DropdownMenuTrigger>
</DropdownMenu>