Checkbox Group
Shared multiple-selection state for the checkboxes it renders.
Uploads of other types are rejected.
Usage guidelines
- Use
CheckboxGroupfor several values from a visible set. UseComboboxwhen the set is long enough to need search,RadioGroupwhen only one value applies, and a singleCheckboxfor one boolean value. - Compose it as a form field:
Fieldholds the name,Fieldset render={<CheckboxGroup />}provides group semantics,FieldsetLegendnames the group, and each option sits in aFieldItemwith its ownFieldLabel. - Pass
value,defaultValue,onValueChangeanddisabledtoCheckboxGroup, not toFieldset. EachCheckboxonly states which value it stands for. - The group holds the selection of the checkboxes it renders. Selection beyond them, such as other pages or filtered-out rows, stays in the owner's domain state, which hands the group only the part it can show.
- The value is a
string[]. Map stronger domain IDs at the boundary that owns them.
Anatomy
Examples
Parent checkbox
Add a Checkbox with parent and pass every child value to allValues on a controlled group. The parent shows the mixed state when only some children are selected. From a partial selection, it cycles through all, none, and back to that selection.
Selection across pages
The owner keeps the selection for every page. The group receives the current page's share as value and its values as allValues, and onValueChange merges the page's new selection back. Key the group by page so the parent checkbox does not restore a partial selection from another page.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus to the next checkbox in the group. |
| Space | Toggles the focused checkbox. On the parent, cycles through all, none, and the previous partial selection. |
API reference
CheckboxGroup
Provides shared state to a series of checkboxes, including allValues and parent checkbox coordination. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: CheckboxGroupState) => string | undefined) | No default | |
value | string[] | No default | |
defaultValue | string[] | No default | |
onValueChange | ((value: string[], eventDetails: CheckboxGroupChangeEventDetails) => void) | No default | |
allValues | string[] | No default | |
disabled | boolean | false | |
render | ComponentRenderFn<HTMLProps, CheckboxGroupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: CheckboxGroupState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-disabled | Present when the checkbox group is disabled. |