Capítulo 17 de 51
A one-part wrapper around multiple Checkbox.Root children that manages a combined array value and enables a "parent" checkbox that auto-derives its own indeterminate/checked state from its children's state.
CheckboxGroup (from @base-ui/react/checkbox-group) wraps plain Checkbox.Root children (imported from @base-ui/react/checkbox) — the group itself renders one element, not a part hierarchy.aria-labelledby pointing at a sibling label element for the group as a whole; each individual Checkbox.Root still needs its own label (wrapping <label>, sibling htmlFor, or Field.Label).value/defaultValue/onValueChange on CheckboxGroup is the array of checked checkbox values combined across all children.CheckboxGroup controlled, 2) pass every child's value in allValues on CheckboxGroup, 3) add parent boolean prop to the designated parent Checkbox.Root. The group then automatically drives that parent checkbox's indeterminate state when some-but-not-all children are checked.<Field.Root name="..."> + <Fieldset.Root render={<CheckboxGroup />}> + <Fieldset.Legend>, with each option in <Field.Item> — the same Fieldset-grouping pattern used for Radio Group (ch009 Forms).| Part | Notable props | Notable data attributes |
|---|---|---|
CheckboxGroup | value/defaultValue/onValueChange, allValues, disabled | data-disabled |
allValues + parent on one child) — omitting allValues leaves the group unable to compute indeterminate state correctly.Fieldset.Root render={<CheckboxGroup />} + Fieldset.Legend (not a bare <div> + heading) so the group's accessible name comes for free via the same mechanism as Radio Group.parent/indeterminate props live on the individual Checkbox.Root, documented in full there.Legend/grouping pattern used for accessible group naming.