Skip to main content

Checkbox Group

View as Markdown

A group of checkboxes for selecting multiple values.

Select options:
<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>
typo3 ui:add checkbox-group

Read more about installing Components and Primitives.

Pre-select multiple options using an array of values.

Notification preferences:

Disable specific checkbox options.

Select plans:

Disable the entire checkbox group.

Select features:

Limit the number of selectable options. Once the limit is reached, remaining unchecked options are automatically disabled.

Pick up to 2 colors:

Implement a "Select All" checkbox that toggles all options.

The following tables cover the available props of the Fluid Primitives.

Provides shared state for a group of related checkboxes. Renders a <div> element.

NameDescriptionRequiredDefault
defaultValuestring[]
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
-
namestring
The name of the input fields in the checkbox group. Useful for form submission. Inherited from a surrounding field when available.
No
-
formstring
The form id the checkbox group belongs to.
No
-
disabledboolean
If true, the checkbox group is disabled. Inherited from a surrounding field when available.
No
-
readOnlyboolean
If true, the checkbox group is read-only. Inherited from a surrounding field when available.
No
-
requiredboolean
If true, the checkbox group is required. Inherited from a surrounding field when available.
No
-
invalidboolean
If true, the checkbox group is invalid. Inherited from a surrounding field when available.
No
-
maxSelectedValuesinteger
The maximum number of selected values.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-disabledPresent when disabled
data-readonlyPresent when read-only
data-invalidPresent when invalid

Labels the checkbox group. Renders a <span> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-disabledPresent when disabled
data-readonlyPresent when read-only
data-invalidPresent when invalid
NameDescriptionDefault
idstring
The unique identifier of the checkbox group.
-
idsRecord<string, string> | undefined
The ids of the elements in the checkbox group. Useful for composition.
-
defaultValuestring[] | undefined
The initial value of the checkbox group (uncontrolled)
-
valuestring[] | undefined
The controlled value of the checkbox group
-
namestring | undefined
The name of the input fields in the checkbox group (for form submission)
-
formstring | undefined
The form id the checkbox group belongs to
-
disabledboolean | undefined
If true, the checkbox group is disabled
-
readOnlyboolean | undefined
If true, the checkbox group is read-only
-
requiredboolean | undefined
If true, the checkbox group is required
-
invalidboolean | undefined
If true, the checkbox group is invalid
-
maxSelectedValuesnumber | undefined
The maximum number of selected values
-
onValueChange((details: { value: string[] }) => void) | undefined
Called when the value changes
-
NameTypeDescription
valuestring[]The current value of the checkbox group
namestring | undefinedThe name for form submission
disabledbooleanWhether the checkbox group is disabled
readOnlybooleanWhether the checkbox group is read-only
invalidbooleanWhether the checkbox group is invalid
isChecked(value: string) => booleanCheck if a value is selected
setValue(value: string[]) => voidSet the entire value array
addValue(value: string) => voidAdd a value to the selection
removeValue(value: string) => voidRemove a value from the selection
toggleValue(value: string) => voidToggle a value
getItemProps(props: CheckboxGroupItemProps) => CheckboxGroupItemStateGet props to merge into a checkbox item