Checkbox Group
Group multiple checkboxes together with shared state management. Supports vertical and horizontal layouts, descriptions, and card-style variants.
Built With
2 componentsThis block uses the following UI components from the design system:
Preview
Basic checkbox group with vertical layout
Notification preferences
Selected: email
Horizontal Layout
Options displayed in a row
Select file types
With Descriptions
Checkboxes with additional context
Email preferences
Receive emails about new products and features
Get notified when we ship new features
Important alerts about your account security
You can change these settings anytime
With Error
Validation error state
Accept terms
You must accept all agreements to continue
Disabled Options
Individual options can be disabled
Features
Upgrade to enable advanced features
Checkbox Card Group
Card-style checkboxes with icons
Select features to enable
Single Column Cards
Full-width card checkboxes
Permissions
CheckboxGroup Props
CheckboxGroup API reference
| Prop | Type | Default | Description |
|---|---|---|---|
options* | CheckboxGroupOption[] | — | Array of checkbox options |
value | string[] | — | Controlled selected values |
defaultValue | string[] | [] | Default selected values (uncontrolled) |
onChange | (value: string[]) => void | — | Callback when selection changes |
label | string | — | Group label |
helperText | string | — | Helper text below group |
error | string | — | Error message |
orientation | 'vertical' | 'horizontal' | 'vertical' | Layout direction |
disabled | boolean | false | Disable entire group |
name | string | — | Name attribute for form submission |
CheckboxCardGroup Props
CheckboxCardGroup API reference
| Prop | Type | Default | Description |
|---|---|---|---|
options* | CheckboxCardOption[] | — | Array of card options with optional icon |
value | string[] | — | Controlled selected values |
defaultValue | string[] | [] | Default selected values |
onChange | (value: string[]) => void | — | Callback when selection changes |
label | string | — | Group label |
columns | 1 | 2 | 3 | 4 | 1 | Number of columns in grid |
disabled | boolean | false | Disable entire group |
Types
Supporting type definitions
interface CheckboxGroupOption { value: string label: string description?: string disabled?: boolean}
interface CheckboxCardOption { value: string label: string description?: string icon?: React.ReactNode disabled?: boolean}Usage
Import and implementation example
import { CheckboxGroup, CheckboxCardGroup } from '@/components/ui/checkbox-group'
export default function Example() { const [selected, setSelected] = useState<string[]>([])
return ( <> {/* Basic checkbox group */} <CheckboxGroup label="Select options" options={[ { value: 'opt1', label: 'Option 1' }, { value: 'opt2', label: 'Option 2' }, { value: 'opt3', label: 'Option 3' }, ]} value={selected} onChange={setSelected} />
{/* Horizontal layout */} <CheckboxGroup options={options} orientation="horizontal" />
{/* Card style with icons */} <CheckboxCardGroup options={[ { value: 'a', label: 'Feature A', icon: <Icon /> }, { value: 'b', label: 'Feature B', icon: <Icon /> }, ]} columns={2} value={selected} onChange={setSelected} /> </> )}Features
Built-in functionality
- Controlled & uncontrolled: Flexible state management options
- Vertical & horizontal: Two layout orientations
- Option descriptions: Additional context for each option
- Error states: Built-in validation message display
- Card variant: Rich card-style checkboxes with icons
- Responsive grid: Card group supports 1-4 column layouts
- Form compatible: Works with native form submission via name prop
Accessibility
Accessibility considerations
ARIA Attributes
Uses role="group" with aria-labelledby for group labelingaria-describedby links to error or helper textEach checkbox has proper label associationKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between checkboxes |
| Space | Toggle checkbox state |
Notes
- Group label announced by screen readers
- Error messages announced via role="alert"
- Disabled state properly conveyed to assistive technology