Create

Form

Combobox

Copy page View as Markdown Open in ChatGPT Open in Claude

A select with a search field that filters the options as you type.

Usage#

app.component.ts
import { WDS_COMBOBOX } from '@wds/angular/combobox';

Examples#

Default#

The field opens a panel with a search field. Selecting an option fires wds-change with its value; selecting the selected option again clears the value. Set search-placeholder and empty-text: their defaults are in Polish.

Angular React Vue Svelte Astro

Groups#

wds-combobox-group with a wds-combobox-label groups the options. The search ignores case and diacritics: type “lodz” or “krakow”. Groups without a match hide.

Poland Warsaw Kraków Łódź Gdańsk Germany Berlin Munich Hamburg Czechia Prague Brno

Keywords#

keywords adds words that match without being shown: type “dollar” or “£”.

Polish złoty (PLN) Euro (EUR) US dollar (USD) British pound (GBP) Swiss franc (CHF)

Disabled#

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

Angular Todo In progress Done Archived

Invalid#

Angular React Vue

Field#

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

Country Poland Germany Czechia Slovakia We ship to these countries only.

With filter="none" the combobox does not filter by itself: it fires wds-search and the app replaces the options (here a simulated 400 ms request). The empty slot shows the loading state and the message when nothing matches.

AmsterdamAthensBarcelonaBerlinBrusselsBudapestCopenhagenDublin No city matches “”.

Forms#

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

Signal forms#

WdsSelectField connects wds-combobox to [formField]; the value is a string.

AssigneeAnna SmithJohn CarterMaria GarciaWei ChenSubmit

Submitted: —

Template-driven#

WdsSelectValueAccessor makes ngModel work on wds-combobox.

AssigneeAnna SmithJohn CarterMaria GarciaWei ChenSubmit

Submitted: —

Reactive forms#

The same WdsSelectValueAccessor works with formControl and formControlName.

AssigneeAnna SmithJohn CarterMaria GarciaWei ChenSubmit

Submitted: —

API References#

wds-combobox#

A select with a search field (a popover with a filtered list). When it opens, focus moves to the search field (role="combobox") and aria-activedescendant points to the active option. Selecting the selected option again clears the value. Works in a form like <select>: name, required, and a reset restores the option with selected.

Attributes

AttributeTypeDefaultDescription
valuestring''Selected value.
placeholderstring''Text of the field when nothing is selected.
search-placeholder.searchPlaceholderstring'Szukaj…'Placeholder of the search field.
empty-text.emptyTextstring'Nie znaleziono.'Message shown when nothing matches. The empty slot takes precedence.
filterWdsComboboxFilter'auto'auto filters the options by their text. none leaves filtering to the app (e.g. results from a server after wds-search).
namestring''Field name in a form. Reflected to the attribute, which FormData uses.
disabledbooleanfalseDisables the field.
requiredbooleanfalseA value is required (valueMissing when empty).
invalidbooleanfalseError state (red border, aria-invalid).
openbooleanfalseWhether the panel is open.

Events

EventDescription
wds-open-changeCustomEvent<WdsComboboxOpenChangeDetail>The panel opens or closes.
wds-changeCustomEvent<WdsComboboxChangeDetail>The user selects an option.
wds-searchCustomEvent<WdsComboboxSearchDetail>The search text changes.

Methods

MethodDescription
show()Opens the panel with the search field.
close()Closes the panel.
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-combobox-item, wds-combobox-group, wds-combobox-separator.
emptyContent shown when nothing matches (instead of empty-text), e.g. a spinner while loading.

CSS parts (::part)

PartDescription
triggerThe field (a button).
valueThe selected option or the placeholder.
contentThe panel.
inputThe search field.
listThe list of options.
emptyThe "no results" message.

CSS custom properties

PropertyDescription
--wds-combobox-list-heightMaximum height of the list (default 300px).

wds-combobox-item#

An option of wds-combobox (role="option"). The selected attribute marks the default selection.

Attributes

AttributeTypeDefaultDescription
keywordsstring''Extra words matched by the search (e.g. synonyms, abbreviations).
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, an <svg> icon).

CSS parts (::part)

PartDescription
indicatorThe check mark.
baseThe row with the padding.

wds-combobox-group#

A group of wds-combobox options (role="group") named by its wds-combobox-label. It hides when none of its options match the search.

Slots

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

wds-combobox-label#

The heading of a group of options. Use it inside wds-combobox-group.

Slots

SlotDescription
(default)Heading text.

CSS parts (::part)

PartDescription
baseThe text with the padding.

wds-combobox-separator#

A line between groups of options. Hidden while searching.

CSS parts (::part)

PartDescription
baseThe line.

Accessibility#

Screen reader#

The field is a native <button> with role="combobox", aria-haspopup="listbox" and aria-expanded. Give it a name: wds-field-label in wds-field, or aria-label on the element. The placeholder is not a name.

When the panel opens, focus moves to the search field (role="combobox", aria-autocomplete="list"). aria-activedescendant points to the active option of the list (role="listbox"); both are named like the field. Without a name the search field is named by search-placeholder.

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

The message shown when nothing matches (empty-text or the empty slot) is a role="status" region, so it is announced.

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

Keyboard support#

KeyFunction
EnterSpaceArrowDownArrowUpOn the field: opens the panel.
A–ZOn the closed field: opens the panel and starts the search with the typed character.
ArrowDownArrowUpIn the search field: moves to the next or previous option.
PageDownPageUpMoves 10 options down or up.
EnterSelects the active option, closes the panel and returns focus to the field.
EscapeCloses the panel without changing the value; focus returns to the field.
TabCloses the panel and moves focus to the next element on the page.
Footer