Checkbox Group

Multiple independent checkbox choices sharing native form values, validation and cleanup with QDS inline choices.

Usage

<form>
  <fieldset><legend>Report review</legend>
    <qds-checkbox-group id="reviewers" name="reviewers" label="Notify reviewers" required hint="Choose one or more internal teams."></qds-checkbox-group>
  </fieldset>
</form>
<script type="module">
  import '/assets/components/checkbox-group/qds-checkbox-group.js';
  reviewers.options = [{value: 'operations', label: 'Operations team'}, {value: 'management', label: 'Asset management'}];
  reviewers.defaultValues = ['operations'];
</script>

API and forms

Grouping and accessibility

Use native fieldset and legend around related fields, including multiple QDS controls. Keeping the fieldset in the same light-DOM form tree preserves native form ownership and disabled behavior; no framework runtime or custom fieldset is required. Style the recipe with existing QDS surface, text and border tokens. Do not replace individual field labels with a legend.

Each named group contains separately tabbable checkbox buttons with checked/readonly/disabled states, visible checked marks and at least 44px targets. Space toggles; native button Enter activation also works. Required-group instructions describe choosing at least one, rather than incorrectly marking every checkbox individually required. Feedback is associated with the group and choices. There is no mixed/select-all parent; compose a clearly labelled application action when needed.

Guidance: W3C grouping controls, APG checkbox.

Quangular business use

The generated string-array forms adapter drives internal reviewer selection in Operations > New update (/#/operations/updates/new). The report requires an internal reviewer, displays selected teams on review and disables reporting fieldsets after a local submission. No notification or persistent write occurs; navigation/reload resets this state. See adjacent test.html for values/reset, external labels, required/custom errors, readonly/disabled and native fieldset examples.

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 first available checkbox. 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.