Skip to content
GitHub (opens in a new tab)

DropdownMenu

Actions or value menu from a button, field, or nav trigger.

stableMoleculecontracts/dropdownmenu.json

Preview

DropdownMenu

Actions from a kit Button. Select is a form list. Command is searchable in a Modal.

One component. Groups and items are data. No Trigger, Content, or Item cousins.

Usage

Act on one thing, up to about ten actions, from a button, ⋯ or nav item. Rows follow size: sm 28px for dense tables, md 32px by default, lg 40px. It opens 4px below, flips above when there is more room there, and caps its height at the screen minus 16px. Type a letter to jump to an item. If people type to find it, use Command; if they pick a value to save, use Select. Do not add Trigger or Item cousins.

Do's

  • A button, ⋯ or nav item that opens a short list of actions on one thing (up to about ten)
  • Row actions in a DataTable via Cell type=actionMenu
  • Select composes this with triggerStyle=field
  • Which one: if people type to find it, use Command. If they act on one thing, use DropdownMenu. If they pick a value to save, use Select.
  • Account menu: triggerStyle account or avatar, header with avatar, footer action Sign out and a version line
  • People or status lists: item avatar for people or workspaces (e.g. Switch account), item dot for a status whose word is the label

Don'ts

  • Choosing one value in a form — use Select (it composes this with triggerStyle=field)
  • Searchable commands — use Command in a Modal
  • Must-choose confirm — use AlertDialog
  • Top-of-page site nav with dropdowns — use NavigationMenu (it composes this with triggerStyle=nav)
<DropdownMenu
  trigger="Open"
  size="md"
  groups={[
    {
      heading: "My account",
      items: [
        { id: "profile", label: "Profile", shortcut: "⇧⌘P" },
        { id: "billing", label: "Billing", shortcut: "⌘B" },
        { id: "settings", label: "Settings", shortcut: "⌘S" },
      ],
    },
    {
      items: [
        { id: "team", label: "Team" },
        {
          id: "invite",
          label: "Invite users",
          submenu: [{ items: [{ id: "email", label: "Email" }, { id: "message", label: "Message" }] }],
        },
        { id: "new-team", label: "New team", shortcut: "⌘T" },
      ],
    },
  ]}
  onSelect={(id) => {}}
/>
  • A button, ⋯ or nav item that opens a short list of actions on one thing (up to about ten)
  • Row actions in a DataTable via Cell type=actionMenu
  • Select composes this with triggerStyle=field
  • Which one: if people type to find it, use Command. If they act on one thing, use DropdownMenu. If they pick a value to save, use Select.
  • Account menu: triggerStyle account or avatar, header with avatar, footer action Sign out and a version line
  • People or status lists: item avatar for people or workspaces (e.g. Switch account), item dot for a status whose word is the label
  • Choosing one value in a form — use Select (it composes this with triggerStyle=field)
  • Searchable commands — use Command in a Modal
  • Must-choose confirm — use AlertDialog
  • Top-of-page site nav with dropdowns — use NavigationMenu (it composes this with triggerStyle=nav)
import { DropdownMenu } from "agentic-ds-kit";
must
  • Field trigger renders aria-haspopup=menu, aria-expanded and aria-controls in server HTML
  • error shows the danger border and Field's error text via aria-describedby; no aria-invalid on the trigger button (button does not support it)
  • Trigger has aria-haspopup=menu, aria-expanded, aria-controls. button is kit Button; field is a field control; nav is a ghost text control
  • With triggerTags, each Tag remove is a sibling button before the trigger in Tab order; the trigger keeps aria-haspopup, aria-expanded, aria-controls
  • Tag avatar and dot are decorative (aria-hidden); the Tag label names it and the trigger name stays the joined labels
  • Panel is role=menu
  • Items are role=menuitem, menuitemcheckbox when checkbox or switch is set, or menuitemradio in a selection="radio" group (aria-checked from selected). A switch item is menuitemcheckbox, never role=switch inside the menu; its kit Switch is aria-hidden and inert. aria-disabled when disabled. With href and not disabled, the item is an a
  • Escape and outside click close; Escape closes only the menu, not a parent Modal, Drawer or AlertDialog; arrows move; Tab closes. Search Input is focused first when searchable
  • Icon-only trigger needs ariaLabel
  • Item with submenu has aria-haspopup=menu and ChevronRight; ArrowRight opens. In a submenu, Escape or ArrowLeft closes only the submenu and focuses its parent item; Escape again closes the menu and focuses the trigger
  • built-in labels (searchOptions) come from KitLabelsProvider; English by default
  • Rows follow size: sm 28px (dense tables and toolbars; 32px when the row has an avatar), md 32px (default, Select), lg 40px. Type, gaps and chips stay the same; the highlight is bg tray with a 2px radius (radius-control-sm) and keyboard focus adds the focus ring
  • An item with a shortcut sets aria-keyshortcuts for a chord; chips are Geist Mono, one per key, and aria-hidden. A sequence such as G I is read as "G then I"; chips are hidden on touch screens and below --grid-breakpoint-sm
  • Typeahead: typing letters moves to the next item whose label starts with them (500ms buffer); a repeated letter cycles through matches
  • Placement: below the trigger by default, 4px away; align start, or end for row and account menus
  • Placement: if the panel does not fit below and there is more room above, it opens above
  • Placement: max height is the screen minus 16px; the list scrolls inside the panel
  • Placement: submenus open to the right; with less than 168px to the right they open left; near the bottom they line up with their row
  • Group separators run the full panel width
  • Checkbox and switch items toggle in place: selecting one keeps the menu open, whatever closeOnSelect says
  • header and footer.meta sit outside the role=menu list and are not focusable; the menu is aria-describedby them, so its name and context are read when it opens. A presence word on the header avatar is in the described text
  • footer.action is a role=menuitem kit Button, last in arrow order; Home and End include it
  • Danger items are never colour alone: an icon and a verb label carry the tone; keep them in their own last group
  • triggerStyle avatar and account: aria-haspopup=menu, aria-expanded, aria-controls; the Avatar is aria-hidden and the presence word joins the accessible name
  • Shortcut chip text is muted in menus so the label leads
  • Item avatar and dot are aria-hidden; the label names the row. An avatar presence word is hidden text after the label, so presence is never colour alone
  • triggerLeading is aria-hidden; the trigger keeps reading its label (plus the presence word when the avatar has one)
  • Typeahead and search match the label only, never the description
  • Highlight: the fill is one decorative layer (aria-hidden) that glides to the highlighted row on hover and arrow keys (submenus follow hover and focus) (clip-path only, --motion-expand-*); it lands in place on first show, after the pointer leaves and on resize or scroll, and jumps with no slide under prefers-reduced-motion. Roles, aria-checked, tabIndex and focus order are unchanged and the focus ring stays on the row
defaults
  • disabled false
  • error false
  • appearance outline
  • mode neutral
  • size md
  • triggerStyle button
  • columns 1
  • closeOnSelect true
  • triggerMuted false
  • searchable false
  • searchPlaceholder Search
stops if
  • Do not invent DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuSub, or DropdownMenuPortal
  • Do not use Select for actions from a button
  • Do not use Command or Modal for a small action menu
  • Do not invent DropdownMenuSub — nest groups on the item, one level
  • Do not invent CheckboxItem or RadioItem cousins — compose kit Checkbox on the item
  • Do not use radix, cmdk, or @base-ui/react
  • Do not use raw hex
  • Do not fake a header with a disabled item or a heading-only group — use header
  • Do not put a kit Switch or Button inside an item — use switch, or footer.action for a full-width button
  • Do not hand-build an avatar or account menu trigger — use triggerStyle avatar or account with triggerAccount
  • Do not build a searchable multi-select of people from this menu — use Select multiple searchable or MultiSelect
  • Do not hand-build an avatar or status dot inside a label or icon — use item avatar or dot
  • Do not use a dot without the state in words in the label or description
  • Do not mix avatar, dot and icon rows in one group; their labels will not line up
  • Do not mix avatar and non-avatar rows in one sm group; avatar rows are 32px and the others 28px

From contracts/dropdownmenu.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

NameTypeRequiredDefaultNotes
triggerDraggablebooleanNo—Makes the trigger button a drag source (TreeView rows use it).
onTriggerDragStartfunctionNo—(event: DragEvent<HTMLButtonElement>) => void on the trigger.
onTriggerDragEndfunctionNo—(event: DragEvent<HTMLButtonElement>) => void on the trigger.
idstringNo—Trigger id for Field htmlFor
disabledbooleanNofalse—
errorbooleanNofalseField and Select composition
describedBystringNo—Field wires hint and error ids onto the trigger
triggerstringNo—Kit Button label. Omit for icon-only; then ariaLabel is required.
iconStartKitIconNo—Icon on the kit Button. A curated Lucide name (PascalCase or kebab-case) renders instantly; any other Lucide name needs import "agentic-ds-kit/icons-on-demand" once (otherwise it is skipped with a dev warning). Or pass the Lucide component (Plus) or an element.
ariaLabelstringNo—required when trigger is omitted
appearancesolid | outline | soft | ghostNooutline—
modeprimary | neutral | dangerNoneutral—
sizelg | md | smNomd—
alignstart | endNo—Default start; end for triggerStyle avatar and account.
groupsarrayYes——
headerobjectNo—Top of the panel, outside the menu list, not focusable. kit Avatar (md) when avatar is set, name, secondary line (e.g. email), kit Badge (neutral) for a plan. Leave out avatar for a text-only header such as a plan line. The menu is aria-describedby the header.
footerobjectNo—Foot of the panel under a full-width divider. action is a full-width kit Button (outline neutral sm) with role=menuitem, last in arrow order; selecting it calls onSelect(id) (e.g. Sign out). meta is one quiet caption line outside the menu list (e.g. a version); the menu is aria-describedby it.
triggerAccountobjectNo—Required for triggerStyle avatar and account. The avatar trigger is named by ariaLabel, else the name plus the presence word.
openbooleanNo—controlled
onOpenChangefunctionNo—(open: boolean) => void
onSelectfunctionNo—(id: string) => void
triggerStylebutton | field | nav | avatar | accountNobuttonbutton is kit Button. field is a full-width control with ChevronsUpDown. Select uses field. nav is a ghost text control with ChevronDown; NavigationMenu uses nav. avatar is a round button around kit Avatar (sm); account is a full-width card with Avatar (sm), name, secondary line and ChevronsUpDown. Both read triggerAccount and default align to end.
iconEndKitIconNo—Icon on a field trigger (default ChevronsUpDown) or kit Button trigger. A curated Lucide name (PascalCase or kebab-case) renders instantly; any other Lucide name needs import "agentic-ds-kit/icons-on-demand" once (otherwise it is skipped with a dev warning). Or pass the Lucide component (Plus) or an element.
columnsenumNo12 uses a CSS grid panel, min-width 28rem. 1 stays a list.
closeOnSelectbooleanNotruefalse keeps the menu open. Select multiple uses false.
triggerMutedbooleanNofalseMuted field trigger text for a placeholder.
triggerBadgestringNo—Kit Badge on a field trigger next to the label, e.g. +2. Select overflow uses this.
triggerTagsarrayNo—Field trigger only. Removable kit Tags in a field wrapper beside the trigger button (not inside it); the button fills the field behind them. Empty array shows the trigger text as a muted placeholder. Select valueDisplay=tags uses this.
onTriggerTagRemovefunctionNo—(id: string) => void. Does not open the menu.
triggerLeadingobjectNo—Field trigger only, not with triggerTags. One mark before the label, aria-hidden: avatar wins, then dot, then icon. Avatar sm (24) at sm and md, md (32) at lg. A presence word joins the trigger name as hidden text. Select sets it from the single picked option.
searchablebooleanNofalseKit Input at the top of the panel. Filters item labels. Select searchable uses this.
searchPlaceholderstringNoSearch—
  • Component
    →

    Select

    Choose one or several options from a list.

  • Component
    →

    Command

    Searchable command menu for quick actions.

  • Component
    →

    Modal

    Dismissible overlay for short tasks, forms, or extra detail.

  • Component
    →

    AlertDialog

    Must-choose overlay that interrupts until the user cancels or confirms.