Create

Form

Select

Copy page View as Markdown Open in ChatGPT Open in Claude

Displays a list of options for the user to pick from, triggered by a button.

Usage#

app.component.ts
import { WDS_SELECT } from '@wds/angular/select';

Examples#

Default#

wds-select-group with a wds-select-label groups the options under a heading.

Fruits Apple Banana Blueberry Grapes Pineapple

Scrollable#

A long list scrolls; wds-select-separator draws a line between groups. Typing letters jumps to the matching option.

North America Eastern Standard Time (EST) Central Standard Time (CST) Mountain Standard Time (MST) Pacific Standard Time (PST) Alaska Standard Time (AKST) Hawaii Standard Time (HST) Europe & Africa Greenwich Mean Time (GMT) Central European Time (CET) Eastern European Time (EET) Western European Summer Time (WEST) Central Africa Time (CAT) East Africa Time (EAT) Asia Moscow Time (MSK) India Standard Time (IST) China Standard Time (CST) Japan Standard Time (JST) Korea Standard Time (KST)

Multiple#

multiple keeps the list open and shows the selected options as badges. The value is values (an array); wds-change reports it in detail.values. In HTML the selected attribute marks the options selected at first.

AngularReactVueSvelteLit

[ "angular", "lit" ]

Size#

Light Dark System Light Dark System Light Dark System

Icons#

Options can have an icon; the field shows only the text of the selected option (or its label).

Card Bank transfer Cash

Disabled#

disabled on the select disables the field; on an option it skips the option.

A Free Pro Enterprise (soon)

Invalid#

Country United States United Kingdom Germany Select a shipping country.

Field#

In wds-field the label and the description become the accessible name and description of the select.

Department Engineering Design Marketing Sales We use it to assign permissions.

Forms#

Integration with Angular forms. Pick the API your app uses.

Signal forms#

WdsSelectField connects a single select to [formField] (a string), and WdsSelectMultipleField a multiple select (a string[]).

LanguageEnglishGermanPolishNotification channelsEmailSMSPushSubmit

Submitted: —

Template-driven#

WdsSelectValueAccessor makes ngModel work on wds-select, for single (string) and multiple (string[]) selects.

LanguageEnglishGermanPolishNotification channelsEmailSMSPushSubmit

Submitted: —

Reactive forms#

The same WdsSelectValueAccessor works with formControl and formControlName.

LanguageEnglishGermanPolishNotification channelsEmailSMSPushSubmit

Submitted: —

API References#

wds-select#

A select list (WAI-ARIA select-only combobox pattern). Focus stays on the field and aria-activedescendant points to the active option. The list opens in the top layer (Popover API). In a form it works like <select>: name, required, reset to the options with the selected attribute.

Attributes

AttributeTypeDefaultDescription
valuestring''Selected value (single mode).
multiplebooleanfalseMultiple selection: the list stays open and the selected options show as badges.
placeholderstring''Text shown when nothing is selected.
namestring''Field name in the form. Reflected to the attribute, which FormData uses.
disabledbooleanfalseDisables the field and excludes it from form submission.
requiredbooleanfalseA value is required for the form to be valid.
invalidbooleanfalseError state (red border, aria-invalid).
sizeWdsSelectSize'default'Field height: sm 32px, default 36px, lg 40px.
max-label-count.maxLabelCountnumber2multiple mode: how many selected options to show as badges, the rest as "+N". 0 = all.
openbooleanfalseWhether the list is open.

Properties

PropertyDescription
valuesstring[]Selected values (multiple mode).

Events

EventDescription
wds-open-changeCustomEvent<WdsSelectOpenChangeDetail>The list opened or closed.
wds-changeCustomEvent<WdsSelectChangeDetail>The user selected an option.

Methods

MethodDescription
show()Opens the list.
close()Closes the list.
formResetCallback()
formDisabledCallback(disabled: boolean)
checkValidity()Returns true when the value is valid; otherwise fires invalid on the element.
reportValidity()Like checkValidity(), and shows the browser validation bubble when the value is invalid.
setCustomValidity(message: string)Sets a custom validation error (an empty string clears it), like input.setCustomValidity().

Slots

SlotDescription
(default)wds-select-item, wds-select-group, wds-select-separator.

CSS parts (::part)

PartDescription
triggerThe field (combobox).
valueThe selected value or the placeholder.
contentThe list of options.

wds-select-item#

An option of wds-select (role="option"). The selected attribute marks an option selected by default (like <option selected>), also for form reset.

Attributes

AttributeTypeDefaultDescription
valuestring''Option value.
labelstring | undefinedText shown in the field when selected. Defaults to the option content.
disabledbooleanfalseDisables the option.

Properties

PropertyDescription
selectedbooleanSelection state. wds-select sets it; the default selection is the selected attribute.

Slots

SlotDescription
(default)Option content (text, <svg> icon).

CSS parts (::part)

PartDescription
baseThe row with the padding.
indicatorThe selection mark.

wds-select-group#

A group of options (role="group"), named by its first label (wds-select-label / wds-combobox-label).

Slots

SlotDescription
(default)wds-select-label and wds-select-item.

wds-select-label#

Heading of a group of options. Use it inside wds-select-group.

Slots

SlotDescription
(default)Heading text.

CSS parts (::part)

PartDescription
baseThe text with the padding.

wds-select-separator#

A line between groups of options (decorative, hidden from screen readers).

CSS parts (::part)

PartDescription
baseThe line.

Accessibility#

Screen reader#

wds-select follows the WAI-ARIA select-only combobox pattern: the field has role="combobox" with aria-expanded and aria-haspopup="listbox", and the list role="listbox" (with aria-multiselectable in multiple mode). Focus stays on the field; aria-activedescendant points to the active option.

Give the select a name: wds-field-label in wds-field, or aria-label on the element. The placeholder is not a name.

Options have role="option" with aria-selected. wds-select-group has role="group" named by its wds-select-label; wds-select-separator and the check marks are hidden from screen readers.

invalid, required and disabled set aria-invalid, aria-required and aria-disabled on the field. In a form the value is submitted under name, and a reset restores the options with selected.

Keyboard support#

KeyFunction
EnterSpaceArrowDownArrowUpOpens the list when it is closed.
ArrowDownArrowUpMoves to the next or previous option.
HomeEndMoves to the first or last option (also opens the list).
PageDownPageUpMoves 10 options down or up.
EnterSpaceSelects the active option; in single mode also closes the list.
Alt + ArrowUpSelects the active option and closes the list (single mode).
EscapeCloses the list without changing the value.
TabIn single mode selects the active option, closes the list and moves focus on.
A–ZOpens the list and moves to the next option starting with the typed letters; Enter selects it.
Footer