UI

Dropdown menu

A focused list of actions, right where you need it.

import { DropdownMenu } from '@uthereal/ui/dropdown-menu'
↵Click or use your keyboard
Loading interactive preview…

Overview

A button that opens a menu of commands: actions, links, checkboxes, radio choices, labelled groups, separators and nested submenus, with optional icons. It reports a named action with the item's ID, keeps checkbox state by item ID, and animates its popup and highlight. The same arguments work in React, in agent compositions, and in agent edits.

Use it for a short list of commands behind one control: file actions, row actions, or view settings. To choose a form value, use Morph select or Multiselect. For one main action with related alternatives, use a button with a menu; to search many commands, a commands palette.

Usage

'use client'
import { DropdownMenu } from '@uthereal/ui/dropdown-menu'

export function FileActions() {
  return (
    <DropdownMenu
      label="Actions"
      items={[
        { kind: 'action', id: 'rename', label: 'Rename', action: 'rename' },
        {
          kind: 'action',
          id: 'duplicate',
          label: 'Duplicate',
          action: 'duplicate',
        },
        { kind: 'separator', id: 'separator' },
        {
          kind: 'checkbox',
          id: 'preview',
          label: 'Show preview',
          defaultChecked: true,
        },
      ]}
      onAction={(action, itemId) => console.log(action, itemId)}
    />
  )
}

The component emits named actions with the item's ID. Your application implements what those actions do. See React and JSON integration for a working example with API-style data, loading, actions and selections shared across both rendering paths.

Examples

Use the playground controls above to inspect trigger variant (outline, solid, ghost) and size (sm, md, lg). The examples below focus on menu composition.

Nested actions

A submenu is an item with its own items array. Item IDs must be unique across the whole menu.

Checkboxes

Checkbox items toggle a setting and keep the menu open, unless the item sets closeOnSelect. They send no action; their state is reported with onCheckedChange.

Any entry but a separator takes an icon; when one row has an icon, every row keeps the icon column so labels align. A link entry navigates with href and sends no action. A group gives its entries a visible heading; the radio entries of a group (or of one popup outside any group) form a single choice, reported through onCheckedChange like checkboxes. React's header slot adds non-interactive content above the items, such as the signed-in identity.

Controlled state

Omit open and checked to let the menu manage itself, or control them with open/onOpenChange and checked/onCheckedChange when selections must survive a remount. The callbacks fire in both modes.

const [checked, setChecked] = useState({ preview: true })

<DropdownMenu
  items={items}
  checked={checked}
  onCheckedChange={setChecked}
/>

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Actions"Visible trigger text and accessible menu name.
iconIconName—Leading trigger icon before the label (15px in secondary text, as Arc's), e.g. ellipsis.
itemsRequiredMenuItem[]—Actions (with an optional icon, shortcut, destructive tone or loading state with loadingLabel), links, checkboxes, radios, labelled groups, separators, and nested submenus. Each item needs a stable, unique ID.
placementPlacementDefault: "bottom-end"Preferred popup position. Collision detection can adjust it.
sizesm | md | lgDefault: "md"Trigger and menu item density.
variantsolid | outline | ghostDefault: "outline"Trigger appearance.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
motionnone | subtle | expressiveDefault: "subtle"Animation preset. System reduced-motion preferences take precedence.
motionOptionsMotionOptions—Popup, highlight, row stagger, label, and chevron overrides. Durations are milliseconds. See Motion.
themeDropdownTheme—Color mode, accent, and semantic tokens. See Theming for all keys and defaults.
dirltr | rtl—Reading direction and submenu navigation. Omit it to inherit the page direction.
closeOnSelectbooleanDefault: trueClose after selecting an action. Checkbox items stay open unless overridden.
loopFocusbooleanDefault: trueWrap keyboard navigation at the first and last items (on by default, as in Arc).
disabledbooleanDefault: falseDisable the trigger.
defaultOpenbooleanDefault: falseInitial open state. Later argument edits do not reset an existing instance.

React integration

PropPurpose
onAction(action, itemId)Handle named actions in your application.
open / onOpenChange(open)Control whether the menu is open.
checked / onCheckedChange(checked, changedId)Control checkbox and radio selections by item ID.
headerNon-interactive content above the items, e.g. the signed-in identity.
sheetBelowBelow this viewport width (px), open as a bottom sheet with drag to close.
presetApplication defaults, overridden by explicit instance arguments.
tokensCSS variables applied after the typed theme, on the trigger and every menu.
renderTrigger(props, state)Render a custom button; forward all supplied props.
triggerRefThe native trigger button.
portalContainerFor a native modal dialog, an element inside its top layer.
classNameAdded to the component root.

Keyboard & accessibility

KeyInteraction
Enter, Space, ↓Open the menu from its trigger (↑ does not).
↑ / ↓Move between enabled items, wrapping at the ends.
Home / EndMove to the first or last enabled item.
→ / ←Enter or leave a submenu; directions reverse in RTL.
Type a labelJump to a matching item.
Enter, SpaceRun the action, follow the link, or pick the option.
EscapeClose the current menu and restore focus.
TabStays in the menu, as in Arc's Radix menu.

As in Arc, the menu is modal: a mouse press on the trigger opens it at once, the page neither scrolls nor takes the pointer while it is open, and a press outside only closes it. The trigger's label names the button and the menu (an icon may lead it, such as ellipsis), so say what the commands are about ("Export", "View options"). Zag supplies the menu semantics, focus management, typeahead and collision handling. Omit dir to inherit the page direction; submenu arrows follow it. Inside a dialog, sheet or popover the menu renders in that overlay's layer and stacks above it. Disabled items are skipped; destructive items are colored and must say what they do.

Motion and theming

As in Arc, the menu grows from its trigger edge: it fades in over 160ms while travelling 5px from scale .97 on Arc's spring, and its rows settle in 35ms apart; it leaves in 130ms to half the travel at .985. A menu that is already open when it mounts appears in place. With sheetBelow, narrow screens get Arc's bottom sheet instead: it rises on the smooth spring over a fading scrim and drops away in 220ms. An action with loading shows a spinner in its icon column, stays open and ignores selection; its loadingLabel rises in place of the label. One highlight per menu fades in over 80ms, glides between items on the snappy spring under the pointer (waiting 70ms before clearing, so it glides across separators), moves at once with the keyboard and eases into the danger tint under a destructive row; a changed trigger label rises out of a soft blur while the old one lifts away and the trigger's width springs to it (at once with reduced motion), and the chevron turns on Arc's spring. Hovering the trigger lifts its edge and fill. motionOptions takes the popup transition, enter and exit poses, highlightDuration (a tween instead of the spring), stagger, the trigger label change (labelDuration, labelOffset) and the chevron (chevronDuration, chevronRotation, chevronEase); durations are milliseconds. none removes the animation; system reduced motion keeps a short linear crossfade of the menu. See the motion reference.

<DropdownMenu
  items={items}
  motion="expressive"
  motionOptions={{
    transition: { type: 'spring', damping: 38 },
    enter: { offset: 6 },
    chevronDuration: 180,
  }}
/>

theme takes a mode, an accent, the core tokens (colors, radius, borderWidth, shadow, typography), the trigger tokens (triggerHeight, triggerPadding, triggerGap; an application-wide controlHeight and controlPaddingX size it like a button), and the popup list tokens shared with UserMenu, Multiselect, and Commands (popupRadius, itemHeight, itemPaddingX, itemRadius, popupMinWidth, popupMaxWidth…). The menu is at least popupMinWidth wide and at most popupMaxWidth (never wider than the room beside the trigger); a longer label wraps between words. The same settings apply to the trigger and every portalled submenu. Recipe and size supply defaults for omitted tokens. An application-wide UtherealProvider supplies defaults; tune them in the Design Playground. Appearance edits preserve checkbox selections and the open menu.

Composition

In an agent composition, DropdownMenu is a leaf. Every item action must name an action the host registered; the host handler receives { componentId, itemId }. Checkbox values are stored at /menus/instance-<id>/checked. See Building with agents.

{
  "type": "DropdownMenu",
  "props": {
    "label": "Export",
    "items": [
      {
        "kind": "action",
        "id": "pdf",
        "label": "PDF document",
        "action": "export_pdf"
      },
      {
        "kind": "action",
        "id": "csv",
        "label": "CSV spreadsheet",
        "action": "export_csv"
      },
      { "kind": "separator", "id": "divider" },
      {
        "kind": "checkbox",
        "id": "headers",
        "label": "Include headers",
        "defaultChecked": true
      }
    ]
  },
  "children": []
}

On this page