Checkbox Group
Groups related checkboxes with a shared label, hint text, and validation state.
import {CheckboxGroup} from "@qualcomm-ui/react/checkbox-group"Examples
Simple
Use the simple API to create a checkbox group using minimal markup.
If you omit the label, you should provide an aria-label prop to keep your group accessible.
<CheckboxGroup hint="Select at least one" label="Notifications">
<Checkbox label="Email" />
<Checkbox label="SMS" />
<Checkbox label="Push" />
</CheckboxGroup>
Composite
Use the composite API for granular control over the group structure.
<CheckboxGroup.Root>
<CheckboxGroup.Label>Notifications</CheckboxGroup.Label>
<CheckboxGroup.Items>
<Checkbox label="Email" />
<Checkbox label="SMS" />
<Checkbox label="Push" />
</CheckboxGroup.Items>
<CheckboxGroup.Hint>Select at least one</CheckboxGroup.Hint>
</CheckboxGroup.Root>
Size
The size prop controls the size of child checkboxes. Available sizes are sm, md (default), and lg.
import type {ReactElement} from "react"
import {Checkbox} from "@qualcomm-ui/react/checkbox"
import {CheckboxGroup} from "@qualcomm-ui/react/checkbox-group"
export function CheckboxGroupSizeDemo(): ReactElement {
return (
<div className="flex flex-row gap-8">
<CheckboxGroup label="Small" size="sm">
<Checkbox label="Email" />
<Checkbox label="SMS" />
</CheckboxGroup>
<CheckboxGroup label="Medium" size="md">
<Checkbox label="Email" />
<Checkbox label="SMS" />
</CheckboxGroup>
<CheckboxGroup label="Large" size="lg">
<Checkbox label="Email" />
<Checkbox label="SMS" />
</CheckboxGroup>
</div>
)
}Orientation
Use the orientation prop to control the layout direction of the group. Options include:
vertical: checkboxes are laid out in a column (default).horizontal: checkboxes are laid out in a row.
<CheckboxGroup label="Notifications" orientation="horizontal">
<Checkbox label="Email" />
<Checkbox label="SMS" />
<Checkbox label="Push" />
</CheckboxGroup>
Indented
Set indented to add padding at the start of the group.
<CheckboxGroup indented label="Notifications">
<Checkbox label="Email" />
<Checkbox label="SMS" />
<Checkbox label="Push" />
</CheckboxGroup>
Hint
Use hint to add additional guidance or context to the user below the group.
<CheckboxGroup hint="Select at least one" label="Notifications">
<Checkbox label="Email" />
<Checkbox label="SMS" />
<Checkbox label="Push" />
</CheckboxGroup>
Error Text
Set invalid and errorText to display validation errors. The error text replaces the hint when present.
<CheckboxGroup
errorText="Select at least one option"
invalid
label="Notifications"
>
<Checkbox label="Email" />
<Checkbox label="SMS" />
</CheckboxGroup>
API
<CheckboxGroup>
| Prop | Type | Default |
|---|---|---|
Error message displayed when invalid. | string | |
Helper text displayed below items. | string | |
Adds padding at the start of the items container. | boolean | |
Marks the group as invalid. | boolean | |
Group label text. | string | |
Layout direction for items. | | 'vertical' | 'vertical' |
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement | |
The size of the group items. | | 'sm' | 'md' |
Type
stringDescription
Error message displayed when invalid.
Type
stringDescription
Helper text displayed below items.
Type
booleanDescription
Adds padding at the start of the items container.
Type
booleanDescription
Marks the group as invalid.
Type
stringDescription
Group label text.
Type
| 'vertical'
| 'horizontal'
Description
Layout direction for items.
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more
Type
| 'sm'
| 'md'
| 'lg'
Description
The size of the group items.
Composite API
<CheckboxGroup.Root>
| Prop | Type | Default |
|---|---|---|
Adds padding at the start of the items container. | boolean | |
Marks the group as invalid. | boolean | |
Layout direction for items. | | 'vertical' | 'vertical' |
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement | |
The size of the group items. | | 'sm' | 'md' |
Type
booleanDescription
Adds padding at the start of the items container.
Type
booleanDescription
Marks the group as invalid.
Type
| 'vertical'
| 'horizontal'
Description
Layout direction for items.
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more
Type
| 'sm'
| 'md'
| 'lg'
Description
The size of the group items.
| Attribute / Property | Value |
|---|---|
className | 'qui-field-group__root' |
data-invalid | |
data-part | 'root' |
data-scope | 'field-group' |
classNameValue
'qui-field-group__root'data-invalidValue
data-partValue
'root'data-scopeValue
'field-group'<CheckboxGroup.Label>
Label for the field group. Renders a
<legend> element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more
| Attribute / Property | Value |
|---|---|
className | 'qui-field-group__label' |
data-part | 'label' |
data-scope | 'field-group' |
classNameValue
'qui-field-group__label'data-partValue
'label'data-scopeValue
'field-group'<CheckboxGroup.Items>
Container for the field group items. Renders a
<div> element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more
| Attribute / Property | Value |
|---|---|
className | 'qui-field-group__items' |
data-indented | |
data-orientation | | 'vertical' |
data-part | 'items' |
data-scope | 'field-group' |
data-size | | 'sm' |
classNameValue
'qui-field-group__items'data-indentedValue
data-orientationValue
| 'vertical'
| 'horizontal'
data-partValue
'items'data-scopeValue
'field-group'data-sizeValue
| 'sm'
| 'md'
| 'lg'
<CheckboxGroup.Hint>
Hint text for the field group. Renders a
<div> element by default.| Prop | Type |
|---|---|
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement |
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more
| Attribute / Property | Value |
|---|---|
className | 'qui-field-group__hint' |
data-part | 'hint' |
data-scope | 'field-group' |
classNameValue
'qui-field-group__hint'data-partValue
'hint'data-scopeValue
'field-group'<CheckboxGroup.ErrorText>
Error text for the field group. Renders a
<div> element by default.Type
| LucideIcon
| ReactNode
Description
An icon to display next to the error text.
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more
| Attribute / Property | Value |
|---|---|
className | 'qui-field-group__error-text' |
data-part | 'error-text' |
data-scope | 'field-group' |
classNameValue
'qui-field-group__error-text'data-partValue
'error-text'data-scopeValue
'field-group'
<fieldset>element by default.