structyl

Dropdown Menu

stable

Displays a menu to the user — such as a set of actions or functions — triggered by a button.

Basic usage

Examples

With checkboxes and radio items

Toggle options and select an exclusive value inside a dropdown.

Rich action menu

Use labels, separators, checkbox items, radio items and shortcuts in one menu.

Features

  • Can be controlled or uncontrolled.
  • Supports submenus with configurable reading direction.
  • Supports items, labels, groups of items.
  • Supports checkable items (single or multiple).
  • Customize side, alignment, offsets, collision handling.
  • Focus is fully managed; full keyboard navigation; typeahead support.

Installation

bash
pnpm dlx structyl add dropdown-menu

API Reference

DropdownMenu.Root

Contains all dropdown-menu parts.

PropTypeDefault
openboolean

Controlled open state.

defaultOpenboolean

Initial open state.

onOpenChange(open: boolean) => void

Called when open state changes.

dir'ltr' | 'rtl'

Reading direction.

modalboolean

Whether outside interaction is disabled.

true

DropdownMenu.Trigger

The button that opens the menu.

PropTypeDefault
asChildboolean

Merge props onto the immediate child instead of rendering a default element.

false

DropdownMenu.Content

The menu surface.

PropTypeDefault
side'top' | 'right' | 'bottom' | 'left'

Preferred side.

sideOffsetnumber

Distance from the trigger.

align'start' | 'center' | 'end'

Alignment.

loopboolean

Whether arrow navigation wraps.

false

DropdownMenu.Item

A selectable menu item.

PropTypeDefault
onSelect(event: Event) => void

Called on selection. preventDefault to keep open.

disabledboolean

Disable the item.

false
insetboolean

Indent to align with checkable items.

DropdownMenu.CheckboxItem

An item with a checkable state.

PropTypeDefault
checkedboolean | 'indeterminate'

Checked state.

onCheckedChange(checked: boolean) => void

Called when toggled.

DropdownMenu.RadioGroup

Groups radio items.

PropTypeDefault
valuestring

Selected value.

onValueChange(value: string) => void

Called on change.

DropdownMenu.RadioItem

An exclusive radio item.

PropTypeDefault
valuestring

The item value.

DropdownMenu.Sub

Wraps a submenu.

PropTypeDefault

DropdownMenu.SubTrigger

Opens a submenu.

PropTypeDefault

DropdownMenu.SubContent

The submenu surface.

PropTypeDefault

DropdownMenu.Label

A non-interactive group label.

PropTypeDefault

DropdownMenu.Separator

A visual divider.

PropTypeDefault

Keyboard interactions

Adheres to the WAI-ARIA design pattern .

KeyDescription
Space / EnterOpens the menu and focuses the first item.
ArrowDown / ArrowUpMoves focus between items.
ArrowRight / ArrowLeftOpens / closes a submenu.
EscCloses the menu and returns focus to the trigger.
Dropdown Menu | structyl