Dropdown Menu

A compact action list with nested choices, checkboxes, and radio preferences.

Interactive preview

Live specimenTry the component

Installation

Add editable source to an initialized React project. Set up antiflex/ui first if you are new here.

Terminal
npx antiflex-ui@0.1.0-alpha.2 add dropdown-menu

This site previews the latest workspace styles and motion. The published alpha keeps its released styles until the next npm release.

Usage

React
<DropdownMenu>
  <DropdownMenuTrigger>Project actions</DropdownMenuTrigger>
  <DropdownMenuContent aria-label="Project actions">
    <DropdownMenuItem onSelect={duplicateProject}>Duplicate project</DropdownMenuItem>
    <DropdownMenuCheckboxItem checked={pinned} onCheckedChange={setPinned}>Pin project</DropdownMenuCheckboxItem>
    <DropdownMenuSeparator />
    <DropdownMenuItem disabled>Delete project</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

API reference

All components forward native attributes, className, and refs to their underlying elements.

PropTypeDefault
Root / Sub: open, defaultOpen, onOpenChangeboolean, boolean, (open: boolean) => voiduncontrolled, closed
Content: sizesm | md | lgmd: 240px, 32px minimum item
Content: side / align / sideOffset / collisionPaddingtop | right | bottom | left; start | center | end; pxbottom/start/4/8; submenu right (left in RTL)
Item / Link: onSelect(event: Event) => voidpreventDefault cancels automatic close; Link also cancels navigation
Item: disabled / variant / textValue / closeOnSelectboolean / default | danger / string / booleanfalse / default / visible text / true
CheckboxItem: checked / defaultChecked / onCheckedChangeboolean / boolean / (checked: boolean) => voiduncontrolled; stays open by default
RadioGroup: value / defaultValue / onValueChangestring / string / (value: string) => voidconsumer labels the group; RadioItem supplies value
Sub + SubTrigger + Contentcomposable nested menuclick, Enter, Space or directional arrow opens; no hover timer
Shortcutnative span attributes and refvisual hint only; does not register keyboard shortcuts

Accessibility

Trigger supports native button attributes/refs. Enter/Space/ArrowDown open at the first item; ArrowUp opens at the last. Provide an accessible menu name with aria-label/aria-labelledby or a named Trigger. Arrow keys wrap among items; Home/End and buffered typeahead work in each menu. Disabled items remain focusable (aria-disabled) but never invoke callbacks. Enter/Space activate native buttons. Checkbox/radio items expose checked state and stay open unless closeOnSelect is true. RadioGroup/Group require an accessible label when needed. Submenus open by click, Enter/Space or the forward arrow (reversed in RTL); the backward arrow/Escape closes one level. Tab/Shift+Tab close the entire tree and move beyond the root invoker; they do not cycle inside menus. Outside press/release or focus exit requests dismissal. Focus returns after Escape/selection when still owned by the menu; an action opening a dialog retains its new focus. Controlled consumers must honor onOpenChange to close. Content uses native popover top-layer support and ResizeObserver, flips/clamps to the visual viewport, and stays mounted when closed. Menu parts must remain DOM descendants of their owning Content; custom wrappers are supported. Do not put form fields or other tabbable controls inside a menu; use Popover for that task. Root/Sub have no DOM/ref. Trigger/Item/CheckboxItem/RadioItem/SubTrigger forward button refs, Link an anchor, Content/Group/RadioGroup/Label/Separator divs and Shortcut a span. Shortcut text does not install global bindings. No hover-open submenu or touch long-press recognizer is included.