Checkbox Group
How to use the CheckboxGroup component for managing multiple checkboxes
Checkbox Group
Learn how to use the CheckboxGroup component to manage multiple related checkboxes.
Basic Example
Horizontal Layout
Label Placement
Props
Prop | Type | Default |
---|---|---|
children | ReactNode | - |
value | string[] | - |
defaultValue | string[] | - |
onChange | (value: string[]) => void | - |
disabled | boolean | - |
name | string | - |
orientation | "horizontal" | "vertical" | - |
spacing | "sm" | "md" | "lg" | - |
labelPlacement | LabelPlacement | - |
className | string | - |
error | boolean | - |
aria-label | string | - |
aria-labelledby | string | - |
Usage Examples
Controlled Group
With Form Integration
Best Practices
-
Group Organization:
- Group related options together
- Use clear, descriptive labels
- Consider using sections for large groups
-
Layout:
- Choose appropriate orientation
- Use consistent spacing
- Consider responsive design
-
Accessibility:
- Provide group labels
- Use semantic HTML
- Maintain keyboard navigation
-
State Management:
- Choose between controlled and uncontrolled
- Handle state changes efficiently
- Consider form integration needs