Create

Form

Accordion Multiselect

Copy page View as Markdown Open in ChatGPT Open in Claude

Select multiple options grouped in expandable sections.

Usage#

app.component.ts
import { WDS_ACCORDION_MULTISELECT } from '@wds/angular/accordion-multiselect';

Examples#

Default#

Options are grouped in wds-accordion-item sections that expand independently. In HTML value and expanded are space-separated lists; show-checkbox adds a checkbox to each option.

Classic manicure
Cuticle care, shaping and polish.
$30
45 min
French manicure
Classic white tips.
$40
60 min
Gel manicure
Long-lasting color for up to three weeks.
$45
75 min
Spa pedicure
Scrub, mask and foot massage.
$60
90 min
Hydrogen cleansing
Deep cleansing and hydration.
$70
60 min
Chemical peel
Evens out skin tone and texture.
$80
45 min
Kobido massage
Japanese lifting massage.
$85
60 min

Without checkbox#

Without show-checkbox a selected option is marked by its background (--wds-accordion-option-selected).

Classic manicure
Cuticle care, shaping and polish.
$30
45 min
French manicure
Classic white tips.
$40
60 min
Gel manicure
Long-lasting color for up to three weeks.
$45
75 min
Spa pedicure
Scrub, mask and foot massage.
$60
90 min
Hydrogen cleansing
Deep cleansing and hydration.
$70
60 min
Chemical peel
Evens out skin tone and texture.
$80
45 min
Kobido massage
Japanese lifting massage.
$85
60 min

Hide count#

By default the header of a section shows how many of its options are selected; hide-count turns it off.

Classic manicure
Cuticle care, shaping and polish.
$30
45 min
French manicure
Classic white tips.
$40
60 min
Gel manicure
Long-lasting color for up to three weeks.
$45
75 min
Spa pedicure
Scrub, mask and foot massage.
$60
90 min
Hydrogen cleansing
Deep cleansing and hydration.
$70
60 min
Chemical peel
Evens out skin tone and texture.
$80
45 min
Kobido massage
Japanese lifting massage.
$85
60 min

Controlled#

value is an array of the selected option values; wds-change reports it in detail.value, with the toggled option and its new selected state.

Classic manicure
Cuticle care, shaping and polish.
$30
45 min
French manicure
Classic white tips.
$40
60 min
Gel manicure
Long-lasting color for up to three weeks.
$45
75 min
Spa pedicure
Scrub, mask and foot massage.
$60
90 min
Hydrogen cleansing
Deep cleansing and hydration.
$70
60 min
Chemical peel
Evens out skin tone and texture.
$80
45 min
Kobido massage
Japanese lifting massage.
$85
60 min
Selected: frenchClear

Disabled#

disabled on the control disables every option; on an option it disables that option.

Classic manicure
Cuticle care, shaping and polish.
$30
45 min
French manicure
Classic white tips.
$40
60 min
Gel manicure
Long-lasting color for up to three weeks.
$45
75 min
Spa pedicure
Scrub, mask and foot massage.
$60
90 min
Hydrogen cleansing
Deep cleansing and hydration.
$70
60 min
Chemical peel
Evens out skin tone and texture.
$80
45 min
Kobido massage
Japanese lifting massage.
$85
60 min

Forms#

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

Signal forms#

WdsAccordionMultiselectField connects the control to [formField] (a string[]). required() treats an empty array as a value, so use minLength(path, 1) for "at least one".

Services
Classic manicure$30
Gel manicure$45
Spa pedicure$60
Hydrogen cleansing$70
Chemical peel$80
Book

Submitted: —

Template-driven#

WdsAccordionMultiselectValueAccessor makes ngModel work on the control; required needs at least one selected option.

Services
Classic manicure$30
Gel manicure$45
Spa pedicure$60
Hydrogen cleansing$70
Chemical peel$80
Book

Submitted: —

Reactive forms#

The same WdsAccordionMultiselectValueAccessor works with formControl and formControlName; Validators.required fails for an empty array.

Services
Classic manicure$30
Gel manicure$45
Spa pedicure$60
Hydrogen cleansing$70
Chemical peel$80
Book

Submitted: —

API References#

wds-accordion-multiselect#

Multiple selection of options grouped in expandable sections (wds-accordion-item with wds-accordion-option). Sections expand independently, and the header of a section shows how many of its options are selected. A form control like <select multiple>: each selected option is a separate name entry in FormData, required needs at least one option, and a form reset restores the initial selection.

Attributes

AttributeTypeDefaultDescription
valuestring[]Values of the selected options. In HTML a space-separated list: value="a b".
expandedstring[]Values (value) of the expanded sections. In HTML a space-separated list.
namestring''Field name in the form.
requiredbooleanfalseAt least one option must be selected for the form to be valid.
disabledbooleanfalseDisables the whole control.
invalidbooleanfalseError state (e.g. from the app validation).
show-checkbox.showCheckboxbooleanfalseShows a checkbox next to each option.
hide-count.hideCountbooleanfalseHides the count of selected options in the section headers.

Events

EventDescription
wds-changeCustomEvent<WdsAccordionMultiselectChangeDetail>The user changed the selection.
wds-open-changeCustomEvent<WdsAccordionOpenChangeDetail>The user expanded or collapsed a section.

Methods

MethodDescription
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-accordion-item sections with wds-accordion-option options.

wds-accordion-option#

A selectable option of wds-accordion-multiselect. The whole row is a toggle (role="checkbox"): a click, Space or Enter changes the selection. The content is free. The state is in data-state="checked|unchecked".

Attributes

AttributeTypeDefaultDescription
valuestring''Option value in the value of the parent.
disabledbooleanfalseDisables the option.

Slots

SlotDescription
(default)Option content (e.g. name, description, price).

CSS parts (::part)

PartDescription
baseThe row with the padding and the border.
indicatorThe checkbox (with show-checkbox on the parent).
checkThe check icon.
contentThe content container.

CSS custom properties

PropertyDescription
--wds-accordion-option-selectedBackground of a selected option.

Accessibility#

Screen reader#

wds-accordion-multiselect has role="group": give it a name with aria-label, or wds-field-label in wds-field.

Each section header is a button inside a heading, with aria-expanded and aria-controls; the section content has role="region" named by the header. The count of selected options in the header is visual only.

Each wds-accordion-option has role="checkbox" with aria-checked, named by its content. The optional checkbox and check icon are hidden from screen readers.

invalid and disabled set aria-invalid and aria-disabled on the group, and a disabled option gets aria-disabled. In a form each selected option is submitted as a separate name entry.

Keyboard support#

KeyFunction
TabMoves focus through the section headers and the options of expanded sections.
EnterSpaceOn a header expands or collapses the section; on an option selects or clears it.
ArrowDownArrowUpOn a header moves to the next or previous section header, wrapping around.
HomeEndOn a header moves to the first or last section header.
Footer