Skip to content
English

How it works

No portal and no position: fixed: the panel hangs under a relative root, so it stays right inside scaled containers, scroll areas and dialogs, but an ancestor's overflow: hidden clips it and it never flips. The panel exists only while open: a 20px-radius card that scales from 0.94 and drops 6px into place from the trigger's corner, its rows following 14ms apart; closing plays a faster exit before unmounting. Focus really moves into the items, so the highlight pill is :focus and mouse and keyboard share it.

Use it for

  • “More actions” on table rows and order cards: tuck 3 to 7 less common actions into one button.
  • Secondary toolbar actions and “click to run” choices such as export or sort options.
  • A “⋯” menu in a card corner (an icon as trigger, aria-label in triggerProps).

Look elsewhere when

  • Picking a value that stays selected, such as a form field: use a select or multi-select, which are listbox or combobox, not menu.
  • An ancestor with overflow: hidden that the panel would exceed: it gets clipped, so use a portal-based solution.
  • More than 8 to 10 items or nested submenus: use a drawer, a command palette or a separate page.
  • The main action on mobile: use a bottom sheet, which is easier to reach with a thumb.

Usage

import { DropdownMenu } from './DropdownMenu.jsx'

const items = [
  { key: 'link', label: 'Copy link', icon: <LinkIcon />, shortcut: '⌘L' },
  { key: 'invite', label: 'Invite people', icon: <UserPlusIcon />, shortcut: '⌘I' },
  { key: 'pdf', label: 'Export as PDF', disabled: true },
  { type: 'separator' },
  { key: 'stop', label: 'Stop sharing', icon: <BlockIcon />, danger: true },
]

export function ShareMenu({ doc }) {
  return (
    <DropdownMenu
      label="Share"
      placement="bottom-end"
      items={items}
      onSelect={(key) => {
        if (key === 'link') navigator.clipboard.writeText(doc.url)
        if (key === 'stop') confirmStopSharing(doc)
      }}
    />
  )
}

// Icon-only trigger: content goes in trigger, the accessible name in triggerProps
// <DropdownMenu trigger={<MoreIcon />} triggerProps={{ 'aria-label': 'More actions' }} items={items} onSelect={handle} />

Props

PropTypeDefaultWhat it does
itemsDropdownMenuItem[]—Menu items: { key, label, icon?, shortcut?, danger?, disabled?, textValue? }. shortcut is shown as a small muted chip. { type: 'separator' } is a divider.
onSelect(key) => void—Called when an item is chosen; the menu then closes and focus returns to the trigger.
triggerReactNode—Custom trigger content, such as a “⋯” icon. When set, the label and arrow are hidden and the button becomes a round, transparent icon button. The outer element is still the component's own <button>; do not nest another.
labelReactNode'More'Text of the default pill trigger, followed by an arrow that flips when open.
placement'bottom-start' | 'bottom-end' | 'top-start' | 'top-end''bottom-start'Panel position relative to the trigger. It does not flip automatically; choose a direction near container edges.
openboolean—Controlled open state, used with onOpenChange.
defaultOpenbooleanfalseInitial open state when uncontrolled; it does not take focus.
onOpenChange(open) => void—Called when the open state changes.
disabledbooleanfalseDisables the trigger; an open menu closes.
triggerPropsButtonHTMLAttributes—Attributes passed to the trigger button, such as aria-label and className.
...restHTMLAttributes<HTMLDivElement>—Other attributes, such as className and style, go to the root. Use --ds-menu-z to change the panel's layer (default 30).

Accessibility

  • Follows the WAI-ARIA Menu Button pattern: the trigger has aria-haspopup="menu", aria-expanded and aria-controls; the panel is role="menu" labelled by the trigger; items are role="menuitem" and dividers role="separator".
  • On the trigger, Enter, Space and Down open and focus the first item, Up opens and focuses the last; inside, Up and Down wrap (skipping disabled items), Home and End jump to the ends, and typing jumps by first letter.
  • Esc closes and returns focus to the trigger without closing an outer dialog; Tab closes and moves on; clicking outside or moving focus out closes it.
  • After choosing, focus returns to the trigger; disabled items use aria-disabled, so they are read but cannot be chosen.
  • The highlight pill is the focus, with an extra 2px inset outline for keyboard focus; rows are 38px high, and at least 44px on touch screens.
  • With reduced motion, entering only fades without scaling or row stagger, and closing unmounts at once.

Motion

The panel enters in 220ms ease-out, scaling from 0.94 and dropping 6px from the trigger's corner; rows follow 14ms apart, each moving 4px. It exits in 140ms ease-in. The trigger turns ink and its arrow flips in 240ms; the highlight pill has no transition so it follows the mouse at once.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

DropdownMenu.jsxdropdown-menu.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Overlays
Bottom sheet comes with Pro. Its preview shows once you unlock it.