Create

Navigation

Dropdown

Copy page View as Markdown Open in ChatGPT Open in Claude

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

Usage#

app.component.ts
import { WDS_DROPDOWN } from '@wds/angular/dropdown';

Examples#

Default#

The element in the trigger slot opens the menu. Selecting an item fires wds-select with its value and closes the menu.

Open My Account Profile Billing Settings Log out

Shortcuts#

The shortcut slot shows a keyboard shortcut on the right. It is only displayed: handle the keys yourself.

Open My Account Profile⇧⌘P Billing⌘B Settings⌘S Log out⇧⌘Q

Icons#

An <svg> before the text gets the icon size and spacing.

Open Profile Billing Settings Log out

Checkboxes#

type="checkbox" toggles checked on selection; detail.checked in wds-select is the new state. The menu closes after each change.

ViewAppearanceStatus BarActivity BarPanel

Status Bar: on, Panel: off

Radio group#

wds-dropdown-radio-group keeps one checked type="radio" item in value and fires wds-change.

Panel PositionPanel PositionTopBottomRight

Position: bottom

Destructive#

variant="destructive" marks an item with a dangerous action.

Actions Edit Share Delete

A nested wds-dropdown with a wds-dropdown-item in its trigger slot is a submenu. It opens on hover, click or ArrowRight.

Open Team Invite users Email Message More… New Team⌘T

Complex#

Labels, groups, a submenu, shortcuts and a disabled item in one menu.

Account My Account Profile⇧⌘P Billing⌘B Settings⌘S Keyboard shortcuts⌘K Team Invite users Email Message New Team⌘T GitHub Support API Log out⇧⌘Q

Placement#

side and align place the panel around the trigger. It flips to the other side when there is not enough space.

Top Profile Billing Right Profile Billing Bottom end Profile Billing

Hover#

trigger="hover" also opens the menu when the pointer is over the trigger; a click and the keyboard still work.

Hover Profile Billing Settings

API References#

wds-dropdown#

Dropdown menu (the WAI-ARIA menu button pattern). The panel opens in the top layer (Popover API). A nested wds-dropdown with a wds-dropdown-item in the trigger slot is a submenu.

Attributes

AttributeTypeDefaultDescription
sideWdsDropdownSide | undefinedSide of the trigger. Defaults to bottom, in a submenu right. Flips when there is not enough space.
alignWdsDropdownAlign'start'Alignment along the trigger.
offsetnumber | undefinedDistance from the trigger in px. Defaults to 4, in a submenu 0.
triggerWdsDropdownTrigger'click'hover opens the menu when the pointer is over the trigger (a click still works).
openbooleanfalseWhether the menu is open. Also set by show(), close() and toggle().
disabledbooleanfalseDisables opening the menu.

Events

EventDescription
wds-open-changeCustomEvent<WdsDropdownOpenChangeDetail>The menu opens or closes.
wds-selectCustomEvent<WdsDropdownSelectDetail>An item is selected (bubbles from wds-dropdown-item).

Methods

MethodDescription
show()Opens the menu and moves focus to the panel.
close()Closes the menu (with any open submenus).
toggle()Opens or closes the menu.

Slots

SlotDescription
triggerThe element that opens the menu (e.g. wds-button). In a submenu: a wds-dropdown-item.
(default)Content: wds-dropdown-item, -label, -separator, -group, -radio-group, submenus.

CSS parts (::part)

PartDescription
contentThe menu panel.

CSS custom properties

PropertyDescription
--wds-dropdown-min-widthMinimum width of the panel (default 8rem).

wds-dropdown-item#

A menu item. Selected with a click, Enter or Space; then the menu closes. In the trigger slot of a nested wds-dropdown it opens the submenu.

Attributes

AttributeTypeDefaultDescription
typeWdsDropdownItemType'item'checkbox toggles checked; radio works in a wds-dropdown-radio-group.
valuestring''Identifier passed in wds-select (and the value in a radio group).
checkedbooleanfalseChecked state of a checkbox or radio item.
disabledbooleanfalseDisables the item: it is skipped by the arrow keys and cannot be selected.
variantWdsDropdownItemVariant'default'destructive: the error color (e.g. "Delete").
insetbooleanfalseIndent that aligns the item with checkbox and radio items.

Events

EventDescription
wds-selectCustomEvent<WdsDropdownSelectDetail>The item is selected.

Slots

SlotDescription
(default)Content (text, an <svg> icon).
shortcutKeyboard shortcut shown on the right, e.g. ⌘K. It is only displayed; handle the keys yourself.

CSS parts (::part)

PartDescription
baseThe row with the padding.

wds-dropdown-label#

A heading of a menu section.

Attributes

AttributeTypeDefaultDescription
insetbooleanfalseIndent that aligns the label with checkbox and radio items.

Slots

SlotDescription
(default)Text.

CSS parts (::part)

PartDescription
baseThe text with the padding.

wds-dropdown-separator#

A line between menu sections (role="separator").

CSS parts (::part)

PartDescription
baseThe line.

wds-dropdown-group#

A group of related menu items (role="group").

Slots

SlotDescription
(default)wds-dropdown-item items.

wds-dropdown-radio-group#

A group of type="radio" items with one selected value.

Attributes

AttributeTypeDefaultDescription
valuestring''Value of the checked item.

Events

EventDescription
wds-changeCustomEvent<WdsDropdownChangeDetail>The selected value changes.

Slots

SlotDescription
(default)wds-dropdown-item type="radio" items.

Accessibility#

Screen reader#

The trigger gets aria-haspopup="menu" and aria-expanded. The panel has role="menu"; give the trigger a text or a label that says what the menu is for.

Items have role="menuitem", or menuitemcheckbox / menuitemradio with aria-checked. Disabled items have aria-disabled="true". Groups have role="group" and separators role="separator".

wds-dropdown-label is plain text and is not linked to a group; to name a group, set aria-label on wds-dropdown-group. Give icons aria-hidden="true".

The text in the shortcut slot is part of the item name, so screen readers read it after the label.

Keyboard support#

KeyFunction
EnterSpaceArrowDownOn the trigger: opens the menu and focuses the first item.
ArrowUpOn the trigger: opens the menu and focuses the last item.
ArrowDownArrowUpMoves focus to the next or previous item, wrapping around; disabled items are skipped.
HomeEndMoves focus to the first or last item.
EnterSpaceSelects the focused item and closes the menu; focus returns to the trigger.
ArrowRightOn a submenu trigger: opens the submenu and focuses its first item.
ArrowLeftIn a submenu: closes it and returns focus to its trigger.
EscapeCloses the menu (or the submenu) and returns focus to its trigger.
TabCloses the menu and moves focus to the next element on the page.
A–ZMoves focus to the next item whose text starts with the typed characters.
Footer