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.

Notifications
Select at least one
<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.

Notifications
Select at least one
<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.

Small
Medium
Large
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.
Notifications
<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.

Notifications
<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.

Notifications
Select at least one
<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.

Notifications
Select at least one option
<CheckboxGroup
  errorText="Select at least one option"
  invalid
  label="Notifications"
>
  <Checkbox label="Email" />
  <Checkbox label="SMS" />
</CheckboxGroup>

API

<CheckboxGroup>

PropTypeDefault
React children prop.
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'
| 'horizontal'
'vertical'
Allows you to replace the component's HTML element with a different tag or component. Learn more
| ReactElement
| ((
props: object,
) => ReactElement)
The size of the group items.
| 'sm'
| 'md'
| 'lg'
'md'
Description
React children prop.
Type
string
Description
Error message displayed when invalid.
Type
string
Description
Helper text displayed below items.
Type
boolean
Description
Adds padding at the start of the items container.
Type
boolean
Description
Marks the group as invalid.
Type
string
Description
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>

Root container for the field group. Renders a <fieldset> element by default.
PropTypeDefault
React children prop.
Adds padding at the start of the items container.
boolean
Marks the group as invalid.
boolean
Layout direction for items.
| 'vertical'
| 'horizontal'
'vertical'
Allows you to replace the component's HTML element with a different tag or component. Learn more
| ReactElement
| ((
props: object,
) => ReactElement)
The size of the group items.
| 'sm'
| 'md'
| 'lg'
'md'
Description
React children prop.
Type
boolean
Description
Adds padding at the start of the items container.
Type
boolean
Description
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.

<CheckboxGroup.Label>

Label for the field group. Renders a <legend> element by default.
PropType
React children prop.
Allows you to replace the component's HTML element with a different tag or component. Learn more
| ReactElement
| ((
props: object,
) => ReactElement)
Description
React children prop.
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more

<CheckboxGroup.Items>

Container for the field group items. Renders a <div> element by default.
PropType
React children prop.
Allows you to replace the component's HTML element with a different tag or component. Learn more
| ReactElement
| ((
props: object,
) => ReactElement)
Description
React children prop.
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more

<CheckboxGroup.Hint>

Hint text for the field group. Renders a <div> element by default.
PropType
React children prop.
Allows you to replace the component's HTML element with a different tag or component. Learn more
| ReactElement
| ((
props: object,
) => ReactElement)
Description
React children prop.
Type
| ReactElement
| ((
props: object,
) => ReactElement)
Description
Allows you to replace the component's HTML element with a different tag or component. Learn more

<CheckboxGroup.ErrorText>

Error text for the field group. Renders a <div> element by default.
PropTypeDefault
React children prop.
An icon to display next to the error text.
| LucideIcon
| ReactNode
<CircleAlert />
Allows you to replace the component's HTML element with a different tag or component. Learn more
| ReactElement
| ((
props: object,
) => ReactElement)
Description
React children prop.
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