Checkbox Group
View as MarkdownA group of checkboxes for selecting multiple values.
Select options:
Features
Permalink to heading "Features"- Multiple selection support (unlike RadioGroup which is single selection)
- Optional maximum number of selections via
maxSelectedValues - Full keyboard navigation support
- Syncs with native form elements for proper form submission
- Works with Field component for form integration
<primitives:checkboxGroup.root>
<primitives:checkboxGroup.label />
<primitives:checkbox.root>
<primitives:checkbox.control>
<primitives:checkbox.indicator />
</primitives:checkbox.control>
<primitives:checkbox.label />
<primitives:checkbox.hiddenInput />
</primitives:checkbox.root>
</primitives:checkboxGroup.root>
Installation
Permalink to heading "Installation"typo3 ui:add checkbox-group
Please copy the files manually from GitHub into your project.
Read more about installing Components and Primitives.
Examples
Permalink to heading "Examples"Default Checked
Permalink to heading "Default Checked"Pre-select multiple options using an array of values.
Notification preferences:
Disabled Items
Permalink to heading "Disabled Items"Disable specific checkbox options.
Select plans:
Disabled Group
Permalink to heading "Disabled Group"Disable the entire checkbox group.
Select features:
Maximum Selections
Permalink to heading "Maximum Selections"Limit the number of selectable options. Once the limit is reached, remaining unchecked options are automatically disabled.
Pick up to 2 colors:
Select All
Permalink to heading "Select All"Implement a "Select All" checkbox that toggles all options.
API Reference
Permalink to heading "API Reference"The following tables cover the available props of the Fluid Primitives.
checkboxGroup.root
Permalink to heading "checkboxGroup.root"Provides shared state for a group of related checkboxes. Renders a <div> element.
| Name | Description | Required | Default |
|---|---|---|---|
defaultValue | string[]The initial value of the checkbox group. Use when you don't need to control the value of the checkbox group. Inherited from a surrounding field when available. | No | - |
name | stringThe name of the input fields in the checkbox group. Useful for form submission. Inherited from a surrounding field when available. | No | - |
form | stringThe form id the checkbox group belongs to. | No | - |
disabled | booleanIf true, the checkbox group is disabled. Inherited from a surrounding field when available. | No | - |
readOnly | booleanIf true, the checkbox group is read-only. Inherited from a surrounding field when available. | No | - |
required | booleanIf true, the checkbox group is required. Inherited from a surrounding field when available. | No | - |
invalid | booleanIf true, the checkbox group is invalid. Inherited from a surrounding field when available. | No | - |
maxSelectedValues | integerThe maximum number of selected values. | No | - |
attributes | arrayAdditional attributes that should be rendered on the component where ui:attributes is used. | No | [] |
asChild | booleanIf true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props. | No | - |
rootId | stringThe root ID of the component, used for hydration and identification. | No | - |
ids | arrayThe IDs of of the component parts for composition. | No | [] |
autoMount | booleanWhether the client initializes the component on its own. Set it to false to mount it yourself with `mount()` | No | true |
class | stringThe CSS class(es) to be applied to the component. | No | - |
Rendered data attributes
| Attribute | Description |
|---|---|
data-disabled | Present when disabled |
data-readonly | Present when read-only |
data-invalid | Present when invalid |
checkboxGroup.label
Permalink to heading "checkboxGroup.label"Labels the checkbox group. Renders a <span> element.
| Name | Description | Required | Default |
|---|---|---|---|
attributes | arrayAdditional attributes that should be rendered on the component where ui:attributes is used. | No | [] |
asChild | booleanIf true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props. | No | - |
class | stringThe CSS class(es) to be applied to the component. | No | - |
Rendered data attributes
| Attribute | Description |
|---|---|
data-disabled | Present when disabled |
data-readonly | Present when read-only |
data-invalid | Present when invalid |
Machine options
Permalink to heading "Machine options"| Name | Description | Default |
|---|---|---|
id | stringThe unique identifier of the checkbox group. | - |
ids | Record<string, string> | undefinedThe ids of the elements in the checkbox group. Useful for composition. | - |
defaultValue | string[] | undefinedThe initial value of the checkbox group (uncontrolled) | - |
value | string[] | undefinedThe controlled value of the checkbox group | - |
name | string | undefinedThe name of the input fields in the checkbox group (for form submission) | - |
form | string | undefinedThe form id the checkbox group belongs to | - |
disabled | boolean | undefinedIf true, the checkbox group is disabled | - |
readOnly | boolean | undefinedIf true, the checkbox group is read-only | - |
required | boolean | undefinedIf true, the checkbox group is required | - |
invalid | boolean | undefinedIf true, the checkbox group is invalid | - |
maxSelectedValues | number | undefinedThe maximum number of selected values | - |
onValueChange | ((details: { value: string[] }) => void) | undefinedCalled when the value changes | - |
Machine JavaScript API
Permalink to heading "Machine JavaScript API"| Name | Type | Description |
|---|---|---|
value | string[] | The current value of the checkbox group |
name | string | undefined | The name for form submission |
disabled | boolean | Whether the checkbox group is disabled |
readOnly | boolean | Whether the checkbox group is read-only |
invalid | boolean | Whether the checkbox group is invalid |
isChecked | (value: string) => boolean | Check if a value is selected |
setValue | (value: string[]) => void | Set the entire value array |
addValue | (value: string) => void | Add a value to the selection |
removeValue | (value: string) => void | Remove a value from the selection |
toggleValue | (value: string) => void | Toggle a value |
getItemProps | (props: CheckboxGroupItemProps) => CheckboxGroupItemState | Get props to merge into a checkbox item |