Inline selection from known options, with named groups, separate active and selected states, native form participation and typeahead. Use checkbox group for independently labelled checkboxes and segmented control for a compact row of choices.
<script type="module" src="/assets/components/listbox/qds-listbox.js"></script>
<form id="agenda-form">
<qds-listbox id="agenda" name="opportunity" label="Committee agenda" multiple required></qds-listbox>
<button type="submit">Prepare agenda</button>
<button type="reset">Reset agenda</button>
</form>
<script>
agenda.options = [
{value: 'opp-cedar', label: 'Cedar Crossing Infrastructure', group: 'Midstream'},
{value: 'opp-aurora', label: 'Aurora Flexible Power', group: 'Power'},
];
agenda.defaultValues = ['opp-cedar'];
agenda.addEventListener('change', event => console.log(event.detail.values));
</script>
options is a cloned array of {value, label, group?, description?, disabled?} records. Identities are nonempty strings; labels/descriptions are plain text. Duplicate identities are ignored. Contiguous named groups retain source order. Blank group names produce ordinary ungrouped options.value is the current first selection; values is the current array in source-option order. multiple switches between scalar and array selection. Programmatic writes remain silent. Unavailable/disabled selections do not submit; pending identities can become available when options arrive.value attribute supplies a reset default. defaultValues supplies explicit reset defaults; changing defaults does not replace a dirty current value. Native form reset restores defaults and clears transient typeahead/active state.name participates in native submission; multiple mode creates repeated FormData entries. form associates an external form by ID. Disabled controls are omitted. Native ancestor fieldset disabling cannot be overridden by writing the child’s own disabled=false.aria-activedescendant identifies it. Options expose selection independently with aria-selected.readonly retains navigation and submission while blocking selection. disabled blocks interaction and programmatic focus. Every option has a minimum 44px target. Active and selected states have separate visual indicators, with forced-color support.label, aria-label and aria-labelledby name the listbox. hint and visible errors describe it. Empty lists show the empty-text status, defaulting to “No options available.”required requires at least one available enabled selection. invalid, errorText, setCustomValidity(), checkValidity() and reportValidity() follow the shared choice contract. validate-on is blur (default), input or submit.input and change CustomEvents with {component, value, values, multiple}. Navigation, owner assignments, defaults and resets do not synthesize selection events.qds-validity-change reports {component, valid, validity, message}. focus(options?) focuses the listbox, and does nothing while disabled.size: sm, md (default) or lg. Targets remain at least 44px high.label, options, group, group-label, option, empty, hint, error. --qds-listbox-max-height controls scroll height (default 18rem). Existing QDS tokens provide both themes.multiple. Do not also bind current value/values when the form model owns them. Grouping and option descriptions are structural options, not projected interactive content.checkValidity() checks constraints without moving focus. Native invalid submission, form.reportValidity() and the component’s reportValidity() reveal the error and focus the listbox. Repeated validation preserves visible option labels, selection and normal Tab order. Canceling the native invalid event suppresses the browser’s default validation focus; the validity result remains false. Reset restores the documented defaults.