Checkbox Group
An unstyled checkbox group that manages an array of selected values, select-all toggling, and form integration.
Base Checkbox Group coordinates a set of checkboxes under one string-array value, with optional select-all/mixed state tracking and form field integration.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Anatomy
Section titled “Anatomy”Compose Root, Item, and All:
Rootmanages the selected string array (value/defaultValue),disabled/readOnlypolicies, andariaLabel. CallinggetValue()returns a copy of the array.Itembinds an option by uniquevalueand supports its owndisabledprop. Duplicate item values ignore ambiguous toggles.Allderives checked/mixed state from all enabled items and preserves disabled items’ selections when toggling.
Controlled state, keyboard, and forms
Section titled “Controlled state, keyboard, and forms”- Pass
valuefor controlled mode: user toggles emitvalueChangewithout mutating the controlled prop directly. - Each item is its own Tab stop and toggles on
Space(Enterdoes not toggle). - Inside a
FieldorFormField,Rootintegrates with label activation, required validation, form serialization, and reset.
Root Props
Section titled “Root Props”Passing value selects controlled mode.
| Prop | Type | Default |
|---|---|---|
value | string[] | — |
defaultValue | string[] | [] |
disabled | boolean | false |
readOnly | boolean | false |
ariaLabel | string | '' |
Other parts
Section titled “Other parts”- Item: accepts
valueanddisabled. - All: no props; automatically tracks enabled items in the group.