Dropdown Menu

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

Features

  • Can be controlled or uncontrolled.
  • Supports items, labels, groups of items.
  • Supports checkable items (single or multiple).
  • Customise side, alignment, offsets, collision handling.
  • Optionally render a pointing arrow.
  • Focus is fully managed.
  • Full keyboard navigation.
  • Typeahead support.
  • Dismissing and layering behavior is highly customizable.

Install the component from your command line.

Import the components and piece the parts together.

Create your styled dropdown menu component from the primitive parts.

Contains all the parts of a dropdown menu.

PropTypeDefaultRequired
defaultOpenboolean
openboolean
onOpenChangefunction
idstring

The button that toggles the dropdown menu. By default, the DropdownMenu.Content will position itself against the trigger.

PropTypeDefaultRequired
asenumbutton

The component that pops out when the dropdown menu is open.

PropTypeDefaultRequired
asenumdiv
disableOutsidePointerEventsbooleanfalse
onEscapeKeyDownfunction
onPointerDownOutsidefunction
onInteractOutsidefunction
disableOutsideScrollbooleantrue
portalledbooleantrue
forceMountboolean
anchorRefref
sideenum"bottom"
sideOffsetnumber0
alignenum"center"
alignOffsetnumber0
avoidCollisionsbooleantrue
collisionToleranceboolean0

An optional arrow element to render alongside the dropdown menu. This can be used to help visually link the anchor with the DropdownMenu.Content. Must be rendered inside DropdownMenu.Content.

PropTypeDefaultRequired
asenumsvg
widthnumber10
heightnumber5
offsetnumber

The component that contains the dropdown menu items.

PropTypeDefaultRequired
asenumdiv
disabledboolean
onSelectfunction
textValuestring

Used to group multiple DropdownMenu.Items.

PropTypeDefaultRequired
asenumdiv

Used to render a label. It won't be focusable using arrow keys.

PropTypeDefaultRequired
asenumdiv

An item that can be controlled and rendered like a checkbox.

PropTypeDefaultRequired
asenumdiv
checkedboolean
onCheckedChangefunction
disabledboolean
onSelectfunction
textValuestring

Used to group multiple DropdownMenu.RadioItems.

PropTypeDefaultRequired
asenumdiv
valuestring
onValueChangefunction

An item that can be controlled and rendered like a radio.

PropTypeDefaultRequired
asenumdiv
valuestring
disabledboolean
onSelectfunction
textValuestring

Renders when the parent DropdownMenu.CheckboxItem or DropdownMenu.RadioItem is checked. You can style this element directly, or you can use it as a wrapper to put an icon into, or both.

PropTypeDefaultRequired
asenumspan
forceMountboolean

Used to visually separate items in the dropdown menu.

PropTypeDefaultRequired
asenumdiv

We expose a CSS custom property --radix-dropdown-menu-content-transform-origin. Use it to animate the content from its computed origin based on side, sideOffset, align, alignOffset and any collisions.

We expose data-side and data-align attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations.

You can add special styles to disabled items via the data-disabled attribute.

Use the Separator part to add a separator between items.

Use the Label part to help label a section.

Use the CheckboxItem part to add an item that can be checked.

Use the RadioGroup and RadioItem parts to add an item that can be checked amongst others.

Adheres to the Menu Button WAI-ARIA design pattern and uses roving tabindex to manage focus movement among menu items.

KeyDescription
SpaceActivates the focused item.
EnterActivates the focused item.
ArrowDownMoves focus to the next item.
ArrowUpMoves focus to the previous item.
EscCloses the dropdown menu and moves focus to DropdownMenu.Trigger.