Listbox

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.

Usage

<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>

Selection and options

Keyboard and accessibility

Validation and events

Styling and integration

References

Native validation focus

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.