Checkbox Group
Introduction
Section titled “Introduction”Several related, independent choices. CheckboxGroup renders a <fieldset> and <legend> around native checkboxes that share one field name, with group help text, required and minSelected/maxSelected validation, and one localized validation message for the group. Checkboxes use the same visuals as Checkbox.
- Grouped choicesRelated checkboxes in a fieldset and legend that share one field name.
- Selection limitsRequired, minimum, and maximum selection rules with one group message.
- Option detailsEach option can have a description or be disabled.
- Flexible layoutVertical or horizontal orientation.
Use it for
- Choosing any number of options from a short, visible list (roughly 2 to 10).
- Selections with a minimum or maximum count, such as “pick up to three topics”.
Use something else for
- Exactly one choice: use Radio Group.
- Long or searchable lists: use a multi-select Combobox or Listbox.
- A single yes/no choice: use Checkbox.
Anatomy
<div class="aui-field aui-checkbox-group" data-aui-control> (consumer host) <fieldset class="aui-checkbox-group__fieldset" aria-describedby> <legend class="aui-field__label">Label<span class="aui-field__required" aria-hidden="true">*</span><span class="aui-visually-hidden"> (required)</span></legend> <div class="aui-field__description"> (optional) <div class="aui-checkbox-group__options"> <div class="aui-checkbox-group__option"> (per option) <span class="aui-checkbox-group__box"> <input type="checkbox" class="aui-checkbox-group__input" name value> <span class="aui-checkbox-group__mark"><svg aria-hidden="true"></span> </span> <div class="aui-checkbox-group__text"> <label class="aui-checkbox-group__label" for=input> <div class="aui-checkbox-group__option-description"> (optional) </div> </div> </div> <div class="aui-field__error aui-validation-message"> (when shown) </fieldset></div>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Checkbox Group in the Employee profile form showcase
Section titled “Checkbox Group in the Employee profile form showcase”The part of the Employee profile form showcase that uses Checkbox Group. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Forms showcase: an employee profile form that uses every form control together,// with constraint validation, a cross-field rule, the error summary, reset, and live options.import { Button } from '@absoluteui/components/button';import { Checkbox } from '@absoluteui/components/checkbox';import { CheckboxGroup } from '@absoluteui/components/checkbox-group';import { Combobox } from '@absoluteui/components/combobox';import { Fieldset } from '@absoluteui/components/fieldset';import { Form, type FormSubmitDetail } from '@absoluteui/components/form';import { FormField } from '@absoluteui/components/form-field';import { MultiSelect } from '@absoluteui/components/multi-select';import { NumberInput } from '@absoluteui/components/number-input';import { RadioGroup } from '@absoluteui/components/radio-group';import { Select } from '@absoluteui/components/select';import { Slider } from '@absoluteui/components/slider';import { Switch } from '@absoluteui/components/switch';import { TextInput } from '@absoluteui/components/text-input';import { Textarea } from '@absoluteui/components/textarea';import { ValidationMessage } from '@absoluteui/components/validation-message';import { action, annotate, choice, createShowcase, hostIn, toggle } from './kit.js';
const sc = createShowcase({ title: 'Employee profile', description: 'Every form control in one form: required fields, formats, ranges, a cross-field rule, and an error summary on submit.',});
const form = document.createElement('form');form.className = 'sc-form';form.noValidate = true;sc.stage.append(form);
// Each fieldset declares its controls, so a component's focus view shows its own group.const fieldset = (legend: string, description?: string): HTMLFieldSetElement => { const fs = document.createElement('fieldset'); form.append(fs); Fieldset.enhance(fs, { legend, ...(description ? { description } : {}) }); return fs;};
const DEPARTMENTS = [ { value: 'eng', label: 'Engineering' }, { value: 'fin', label: 'Finance' }, { value: 'hr', label: 'People' }, { value: 'ops', label: 'Operations' }, { value: 'sales', label: 'Sales' },];const MANAGERS = ['Ada Kowalski', 'Bruno Silva', 'Chen Wei', 'Divya Nair', 'Emeka Obi', 'Farah Haddad', 'Grace Liu', 'Hiro Tanaka'].map((name) => ({ value: name.toLowerCase().replace(/\s+/g, '-'), label: name }));const SKILLS = ['Accessibility', 'Angular', 'Data analysis', 'Design systems', 'Finance', 'Negotiation', 'People management', 'TypeScript'].map((s) => ({ value: s.toLowerCase().replace(/\s+/g, '-'), label: s }));
// Personal details.const personal = annotate(fieldset('Personal details'), ['form', 'error-summary', 'fieldset', 'text-input', 'textarea', 'form-field']);const name = TextInput.create(hostIn(personal), { label: 'Full name', name: 'name', required: true, minLength: 2, autocomplete: 'name' });const email = TextInput.create(hostIn(personal), { label: 'Work email', name: 'email', type: 'email', required: true, autocomplete: 'email', description: 'Used for sign-in and notifications.' });const phone = TextInput.create(hostIn(personal), { label: 'Phone', name: 'phone', type: 'tel', inputMode: 'tel', pattern: '[+]?[0-9 ]{7,20}', description: 'Digits and spaces, with an optional leading +.' });const bio = Textarea.create(hostIn(personal), { label: 'About', name: 'bio', maxLength: 280, showCounter: true, rows: 3, resize: 'vertical' });
// A native control labelled and validated by Form Field.const badge = document.createElement('input');badge.name = 'badge';badge.inputMode = 'numeric';badge.pattern = '[0-9]{6}';FormField.create(hostIn(personal), { label: 'Badge number', control: badge, description: 'Six digits printed on your badge.' });
// Role.const role = annotate(fieldset('Role'), ['form', 'error-summary', 'validation-message', 'fieldset', 'select', 'combobox', 'radio-group', 'number-input', 'slider', 'multi-select']);const department = Select.create(hostIn(role), { label: 'Department', name: 'department', options: DEPARTMENTS, placeholder: 'Choose a department', required: true });const manager = Combobox.create(hostIn(role), { label: 'Manager', name: 'manager', options: MANAGERS, placeholder: 'Type a name', description: 'Search by first or last name.' });const type = RadioGroup.create(hostIn(role), { label: 'Employment type', name: 'type', orientation: 'horizontal', required: true, options: [{ value: 'full', label: 'Full time' }, { value: 'part', label: 'Part time' }, { value: 'contract', label: 'Contractor' }] });const salary = NumberInput.create(hostIn(role), { label: 'Annual salary', name: 'salary', min: 10000, max: 500000, step: 1000, format: { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 } });const hours = Slider.create(hostIn(role), { label: 'Weekly hours', name: 'hours', min: 8, max: 48, step: 1, largeStep: 4, value: 40, marks: [{ value: 20, label: '20' }, { value: 40, label: '40' }], showValue: true });const skills = MultiSelect.create(hostIn(role), { label: 'Skills', name: 'skills', options: SKILLS, maxSelected: 5, description: 'Up to five.' });
// Preferences.const prefs = annotate(fieldset('Preferences', 'You can change these later in settings.'), ['form', 'error-summary', 'fieldset', 'checkbox-group', 'switch', 'checkbox']);const benefits = CheckboxGroup.create(hostIn(prefs), { label: 'Benefits', name: 'benefits', orientation: 'horizontal', options: [{ value: 'health', label: 'Health' }, { value: 'pension', label: 'Pension' }, { value: 'transit', label: 'Transit pass' }, { value: 'gym', label: 'Gym' }] });const remote = Switch.create(hostIn(prefs), { label: 'Works remotely', name: 'remote' });const terms = Checkbox.create(hostIn(prefs), { label: 'I confirm these details are correct', name: 'terms', required: true });
// A standalone validation message for a rule that is not tied to one control.const actions = annotate(hostIn(form), ['form', 'error-summary', 'validation-message']);actions.className = 'sc-form__actions';const hint = ValidationMessage.create(hostIn(actions), { tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });
const buttons = hostIn(actions);buttons.className = 'sc-form__buttons';const submit = Button.create({ text: 'Save profile', variant: 'primary', type: 'submit' }, document);const reset = Button.create({ text: 'Reset', variant: 'secondary', type: 'reset' }, document);buttons.append(submit.element, reset.element);
const formController = Form.create(form, { summaryTitle: 'Fix these fields to save the profile', rules: [ { fields: ['type', 'hours'], validate: (values) => (values.type === 'part' && Number(values.hours) > 32 ? 'Part-time employees work at most 32 hours per week.' : null), }, ],});
form.addEventListener('aui-submit', (e) => { const { values } = (e as CustomEvent<FormSubmitDetail>).detail; submit.setLoading(true); // A save takes a moment; the button stays busy and focusable meanwhile. setTimeout(() => { submit.setLoading(false); hint.update({ tone: 'success', message: `Saved the profile of ${typeof values.name === 'string' ? values.name : 'the employee'}.` }); }, 600);});form.addEventListener('aui-reset', () => { hint.update({ tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });});
sc.listen(form, ['aui-submit', 'aui-invalid', 'aui-reset'], 'form');for (const [label, host] of [ ['name', name.host], ['email', email.host], ['department', department.host], ['manager', manager.host], ['type', type.host], ['salary', salary.host], ['hours', hours.host], ['skills', skills.host], ['benefits', benefits.host], ['remote', remote.host], ['terms', terms.host],] as const) { sc.listen(host, ['aui-change'], label);}
// Options.const all = [name, email, phone, bio, department, manager, type, salary, hours, skills, benefits, remote, terms];toggle(sc, 'Disabled', false, (disabled) => { for (const c of all) c.update({ disabled }); badge.disabled = disabled; submit.update({ disabled });});toggle(sc, 'Read-only', false, (readOnly) => { for (const c of [name, email, phone, bio, department, manager, salary, skills]) c.update({ readOnly }); badge.readOnly = readOnly;});choice( sc, 'Validate', [ { value: 'blur', label: 'When leaving a field' }, { value: 'input', label: 'While typing' }, { value: 'submit', label: 'On submit only' }, ], 'blur', (timing) => { for (const c of [name, email, phone, bio, department, type, salary, benefits, terms]) c.update({ validationTiming: timing }); },);action(sc, 'Fill sample data', () => { name.setValue('Ada Lovelace'); email.setValue('ada@example.com'); phone.setValue('+44 20 7946 0000'); bio.setValue('Writes the first programs and reviews every pull request.'); badge.value = '204816'; department.setValue('eng'); manager.setValue('chen-wei'); type.setValue('full'); salary.setValue(86000); hours.setValue(38); skills.setValue(['typescript', 'accessibility']); benefits.setValue(['health', 'pension']); remote.setChecked(true); terms.setChecked(true); sc.log('sample data filled');});action(sc, 'Submit empty', () => { formController.reset(); formController.submit();}, ['form', 'error-summary']);Required group with help text
Section titled “Required group with help text”import { CheckboxGroup } from '@absoluteui/components/checkbox-group';
const host = document.createElement('div');document.body.append(host);CheckboxGroup.create(host, { label: 'Notifications', name: 'notify', description: 'Choose at least one channel.', required: true, options: [ { value: 'email', label: 'Email' }, { value: 'sms', label: 'SMS', description: 'Carrier rates may apply' }, { value: 'push', label: 'Push notification' }, ],});Selection limits, horizontal layout
Section titled “Selection limits, horizontal layout”import { CheckboxGroup } from '@absoluteui/components/checkbox-group';
const host = document.createElement('div');document.body.append(host);const topics = CheckboxGroup.create(host, { label: 'Topics', orientation: 'horizontal', minSelected: 2, maxSelected: 3, options: ['Design', 'Security', 'Performance', 'Accessibility'].map((t) => ({ value: t.toLowerCase(), label: t })),});host.addEventListener('aui-change', () => { host.dataset.count = String(topics.value.length);});Show messages on first change (Mode B)
Section titled “Show messages on first change (Mode B)”import { configureAbsoluteUI } from '@absoluteui/core';
configureAbsoluteUI({ components: { checkboxGroup: { validationTiming: 'input' } } });Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { CheckboxGroup } from '@absoluteui/components/checkbox-group';import '@absoluteui/components/checkbox-group/style.css';First use
Section titled “First use”import { CheckboxGroup } from '@absoluteui/components/checkbox-group';import '@absoluteui/components/checkbox-group/style.css';
const host = document.querySelector<HTMLElement>('#topics');if (host) { const topics = CheckboxGroup.create(host, { label: 'Topics', maxSelected: 3, options: [ { value: 'design', label: 'Design' }, { value: 'security', label: 'Security' }, { value: 'performance', label: 'Performance' }, { value: 'a11y', label: 'Accessibility' }, ], }); host.addEventListener('aui-change', () => { host.dataset.count = String(topics.value.length); });}More usage
import { CheckboxGroup } from '@absoluteui/components/checkbox-group';
const host = document.createElement('div');document.body.append(host);CheckboxGroup.create(host, { label: 'Notifications', name: 'notify', required: true, options: [ { value: 'email', label: 'Email' }, { value: 'sms', label: 'SMS' }, ],});Using Angular? See Checkbox Group for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”CheckboxGroup.create(host: HTMLElement, options: CheckboxGroupOptions): CheckboxGroupGlobal configuration key: checkboxGroup (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Legend text and accessible name of the group. Required. | |
hideLabel |
boolean |
false |
Visually hide the legend; it remains the accessible name. |
options |
readonly { value: string; label: string; description?: string; disabled?: boolean }[] |
Choices; values must be unique. Required. | |
value |
readonly string[] |
"[]" |
Initially selected values; also restored by reset(). |
name |
string |
Form field name shared by every checkbox. | |
description |
string |
Group help text referenced by the fieldset’s aria-describedby. | |
required |
boolean |
false |
At least one option must be selected. |
minSelected |
number |
Minimum selections once any option is selected (integer 1..options.length). | |
maxSelected |
number |
Maximum selections (integer 1..options.length). | |
orientation |
'vertical' | 'horizontal' |
"vertical" |
Layout of the options. |
disabled |
boolean |
false |
Disables the whole group (fieldset disabled). |
validate |
(value: string[]) => string | null |
Consumer validation; return a message to mark the selection invalid. | |
icons |
Partial<{ checked: IconRef; error: IconRef }> |
Icon slot overrides. | |
validationTiming |
'blur' | 'input' | 'submit' |
"blur" |
When validation messages first appear; afterwards they update live. Globally configurable. |
locale |
string |
"en-US" |
Message and number-formatting locale. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
Consumer host; its children are owned by the component. |
fieldset |
HTMLFieldSetElement |
The grouping fieldset. |
inputs |
HTMLInputElement[] |
The native checkboxes, in option order. |
value |
string[] |
Selected values, in option order. |
name |
string | null |
Form field name. |
label |
string |
Legend text. |
disabled |
boolean |
Group disabled state. |
validity |
FieldValidity |
{ valid, error, message }; computed on every change. |
dirty |
boolean |
Selection differs from the initial selection. |
touched |
boolean |
Focus has left the group at least once. |
options |
Readonly<CheckboxGroupOptions> |
Current instance options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
setValue(value: readonly string[]): void |
Programmatic selection (no events); unknown values throw CHECKBOX_GROUP_OPTIONS. |
update(options: Partial<CheckboxGroupOptions>): void |
Merge and apply options; a new option list keeps selections that still exist. |
reportValidity(): boolean |
Show messages now and return validity. |
setCustomError(message: string | null): void |
External error; cleared when the selection changes. |
getFormValue(): string[] |
Selected values for form serialization. |
focus(): void |
Focus the first enabled checkbox. |
reset(): void |
Restore the initial selection and clear dirty/touched/submitted state. |
destroy(): void |
Remove rendering, listeners, registration, and subscriptions. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-change |
{ value: string[]; validity: FieldValidity } |
Yes | No | The user toggled an option. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-field aui-checkbox-group |
Host. |
aui-checkbox-group--invalid | --disabled |
State modifiers on the host. |
aui-field__label | __required | __description | __error |
Shared field chrome (the label is the legend). |
aui-checkbox-group__fieldset |
Grouping fieldset. |
aui-checkbox-group__options | __options--horizontal |
Option list and its horizontal layout. |
aui-checkbox-group__option |
One option row. |
aui-checkbox-group__box | __input | __mark |
Checkbox box, native input, and check mark. |
aui-checkbox-group__text | __label | __option-description |
Option label and help text. |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
checked |
check |
error |
alert-circle |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-color-border | --aui-color-border-strong | --aui-color-disabled-bg | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-on-primary | --aui-color-primary | --aui-color-surface | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-weight-medium | --aui-icon-size-md | --aui-icon-size-sm | --aui-line-height-normal | --aui-line-height-tight | --aui-radius-sm | --aui-space-1 | --aui-space-2 | --aui-space-4 | --aui-touch-target-min
TypeScript definitions
type CheckboxGroupOrientation = 'vertical' | 'horizontal';interface CheckboxGroupOption { value: string; label: string; description?: string; disabled?: boolean }interface CheckboxGroupIcons { checked: IconRef; error: IconRef }interface CheckboxGroupChangeDetail { value: string[]; validity: FieldValidity }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: Native <fieldset> + <legend> grouping native checkboxes, each with a <label for> (HTML; WAI-ARIA APG Checkbox).
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| Tab / Shift+Tab | Any | Moves focus through each enabled checkbox in order. |
| Space | Checkbox focused | Toggles that option (native). |
| Element | Role |
|---|---|
| fieldset | group (native), named by the legend |
| input | checkbox (native) |
| check marks and icons | none (aria-hidden=true) |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-describedby |
fieldset | Group help text and visible error message ids |
aria-describedby |
input | That option’s help text id, when present |
aria-invalid |
input | “true” on every checkbox while the group error is shown (the group role does not support aria-invalid) |
Each native input is a tab stop and shows a color-focus-ring outline on :focus-visible.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- The required asterisk is aria-hidden. Because checkboxes and the group role cannot carry aria-required, a visually hidden “(required)” (localizable message checkboxGroup.required) is part of the legend.
- Checked state is shown by a check mark, not only by the fill color.
- Errors appear after focus leaves the group by default, not when moving between options.
- Announcement of fieldset aria-describedby varies by screen reader; not yet manually verified with NVDA, JAWS, and VoiceOver.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/checkbox-group |
41.8 kB | 14.1 kB | 12.6 kB | 1.0 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| CheckboxGroup.create with 10 options, per instance | < 2 ms average in headless Chromium (target; not yet covered by the performance test) |
Tested scale: Unit-tested with up to 4 options per group; intended for short lists (up to about 20 options).
Two listeners per instance (delegated change, focusout), a shared document-level pointer tracker, and one configuration subscription. Rendering is linear in the number of options. Target: under 2 ms for 10 options; not yet covered by the performance test.
Measured run times: Performance.
Details
Section titled “Details”States
default, hover, focus-visible, checked, disabled (group), disabled (option), required, invalid (message shown).
State transitions
| From | Trigger | To |
|---|---|---|
| any | user toggles an option | selection changed; aui-change; dirty |
| any | focus leaves the group | touched; messages shown (blur timing) |
| any | reportValidity() |
submitted; messages shown for every timing |
| invalid (custom error) | selection changes | custom error cleared |
| any | reset() |
initial selection; pristine, untouched |
Accessibility notes
- The required asterisk is
aria-hidden. Checkboxes and the group role cannot carryaria-required, so a visually hidden “ (required)” (messagecheckboxGroup.required) is part of the legend. - Checked state is shown by a check mark, not only color.
- Errors appear after focus leaves the whole group, not when moving between options.
- Manual screen-reader verification is pending (see Known limitations).
Responsive behavior
Vertical by default. orientation: 'horizontal' wraps options in a row. Labels and help text wrap; rows are at least touch-target-min tall.
Right-to-left
Logical properties and flex layout: boxes are at the inline start and horizontal options flow from the inline start.
Theming
Colors come from role tokens only. In forced-colors mode boxes use Canvas/CanvasText, checked uses Highlight with a HighlightText mark, and disabled uses GrayText, with forced-color-adjust: none.
Global configuration
configureAbsoluteUI({ components: { checkboxGroup: { validationTiming: 'input' } } });Changes apply to existing instances immediately.
Component configuration
Instance options override global and theme defaults. All options are dynamic; changing options, name, or icons rebuilds the option rows.
Icons
icons.checked (default check) and icons.error (default alert-circle).
Security
All text uses textContent. Validation messages never include selected values. CSP-safe.
Data handling
No persistence, network access, or telemetry. With name, each checked native checkbox submits name=value.
Supported data scale
Short lists, up to about 20 options. Unit-tested with 4 options.
Edge cases
- An empty optional group is valid even with
minSelected(HTML constraint semantics); addrequiredto demand a selection. - Required and empty reports
value-missing(“Select an option.”), nottoo-few-selected. - Disabled options keep their checked state and are still reported in
valueandgetFormValue(); native form submission omits disabled inputs. update({ options })drops selections whose values no longer exist.
Errors
| Code | Category | Cause |
|---|---|---|
CHECKBOX_GROUP_OPTIONS |
configuration | Missing label, empty or duplicate options, unknown value, invalid minSelected/maxSelected, minSelected > maxSelected, invalid orientation. |
Validation (validity.error) |
validation | value-missing, too-few-selected, too-many-selected, custom. |
A failed construction leaves no rendering, listeners, or subscriptions behind.
Known limitations
- Selection-count messages have singular and plural forms only (
tooFewSelectedOne/tooFewSelected,tooManySelectedOne/tooManySelected); languages with more plural categories need a customvalidatemessage. - Some screen readers announce fieldset descriptions only when entering the group.
- Screen-reader behavior has not yet been manually verified with NVDA, JAWS, and VoiceOver.
Unsupported scenarios
- HTML in labels or the legend.
- A mixed “select all” row inside the group (compose a Checkbox with the group).
- Nested groups.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.