Componentsv2.189.1
Iconsv1.19.0
MCPv0.8.62
Tokensv0.34.3

A set of actions in a popover.

Structure

The DropdownMenu overlay container is built with a native <div> element with a menu ARIA role to denote it as a list of choices. The DropdownMenu itself renders outside of the document flow in a portal to prevent interference with other elements.

The trigger element and action items are created with buttons and hyperlinks to preserve native interactivity and receive the menuitem ARIA role to link their association with the container. Checkboxes use the menuitemcheckbox role.

Our DropdownMenu uses Floating UI for positioning and interactions, but the library also handles accessibility out of the box. Floating UI's useRole assigns ARIA attributes to the trigger, useListNavigation enables arrow key navigation through menu items, useTypeahead allows jumping to items by typing, and useDismiss handles closing the menu with the Escape key and outside clicks.

ARIA

table
ElementAttributeDescription
Checkbox itemaria-checkedSet to true when the checkbox item is checked.
Checkbox itemrole="menuitemcheckbox"Identifies the item as a checkbox within the menu.
Menu itemaria-currentSet to true on the item that currently has keyboard focus via list navigation.
Menu itemaria-disabledSet to true when the item is disabled, preventing interaction.
Menu itemrole="menuitem"Identifies each action or link as a menu item.
Menu containerrole="menu"Identifies the floating overlay as a menu for assistive technology.
Triggeraria-controlsReferences the id of the menu content when the menu is open.
Triggeraria-expandedSet to true when the menu is open.
Triggeraria-haspopupIndicates the trigger controls a popup element.

Keyboard

Trigger

table
KeyFunction
Enter/SpaceOpens the dropdown menu.
EscapeCloses the dropdown menu and returns focus to the trigger.
table
KeyFunction
Enter/SpaceActivates the focused menu item.
EscapeCloses the menu and returns focus to the trigger.
TabCloses the menu and moves focus to the next focusable element.
Shift+TabCloses the menu and moves focus to the previous focusable element.
Type-aheadTyping a character moves focus to the first menu item whose label starts with that character.
Moves focus to the next menu item. Navigation loops from the last option back to the first.
Moves focus to the previous menu item. Navigation loops from the first option back to the last.
table
KeyFunction
Opens the submenu when a menu with nested items is focused.
/ EscapeCloses the submenu and returns focus to the parent menu.

On this page