Forms
CheckboxGroup
Several independent yes/no choices under one question, as a fieldset with a legend.
- Experimental
- Keyboard not tested yet
- Screen reader not tested yet
Playground
Change the props. The controls come from the documented props.
<CheckboxGroup
label="Contact me by"
name="playground-channels"
options={[{ value: "email", label: "Email" }, { value: "phone", label: "Phone" }]}
/>Usage
When to use
Use a checkbox group when several options under one question can be true at the same time, such as which events send an email or which channels a contact prefers.
When not to use
- For exactly one choice out of several: use RadioGroup (two to five options) or Select.
- For a single yes/no, such as consent: use Checkbox.
How it works
A fieldset with a legend holds one Checkbox per option. All options share one name; the form receives every checked value under it. Each box toggles on its own with Space, and Tab moves from box to box.
Content guidelines
Phrase the legend as the start of a sentence the options complete: “Email me when” followed by “A new request arrives”. Keep options parallel in grammar and roughly the same length.
Do and don’t
Do
- Use it when several options can be true at once, such as which events send an email.
- Name the group by the question, e.g. “Email me when”.
Don’t
- Don't use it for one choice out of several; use RadioGroup.
- Don't use a group for a single yes/no; use Checkbox.
Anatomy
The parts of the component and what each one does, as in the playground above.
- legendThe question, 14px medium.
- optionA Checkbox per option, 24px box with a check mark.
- hintHelp text under the legend.
Examples
Type-checked, and the same code goes into the AI manifest. Import: import { CheckboxGroup } from "@/ds";
Email notifications
Props
Checked against the component's TypeScript type on every build.
| Name | Type | Default | Description |
|---|---|---|---|
| label (required) | string | – | What the options have in common, rendered as the legend. |
| name (required) | string | – | Form field name; every checked value is sent under it. |
| options (required) | CheckboxOption[] | – | value, label and an optional hint per option. |
| defaultValues | string[] | – | Values checked first. |
| optional | boolean | false | Adds “(optional)” to the legend. |
| hint | string | – | Help text under the legend. |
| disabled | boolean | false | Disables every option. |
Tokens used
Derived from the utility classes in the component's source. Copy a class with one click.
| Token | Tier | Value | Utility |
|---|---|---|---|
| spacing.1 | semantic | 4px | |
| spacing.2 | semantic | 8px | |
| spacing.3 | semantic | 12px | |
| text.primary | semantic | #0A0A0B | |
| text.secondary | semantic | #555555 | |
| type.small.size | semantic | 14px | |
| weight.medium | semantic | 500 | |
| weight.regular | semantic | 400 |
Accessibility
What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
| Check | How | Status |
|---|---|---|
| axe-core rules | Automated on every npm run check, at desktop and mobile width | Runs on every build |
| Keyboard | Automated Playwright test (scripts/keyboard.mjs) | Not tested yet |
| Screen reader | Manual | Not tested yet |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves to the next option in the group. |
| Space | Checks or unchecks the focused option. |
Semantics and focus
- <fieldset> and <legend> name the group; screen readers read the legend with each option.