Skip to main content

Checkbox

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Checkbox component allows users to select one or more options from a set. Built on Radix UI's Checkbox primitive, it provides full accessibility support and customizable styling.

Basic Usage

Controlled Checkbox

Status: Unchecked

Checkbox Group

Select your favorite frameworks:

Selected: None

Indeterminate State

Disabled State

Form Integration

Properties

Checkbox

PropertyTypeDefaultDescription
checkedboolean | "indeterminate"-The checked state of the checkbox.
defaultCheckedboolean-The default checked state (uncontrolled).
onCheckedChange(checked: boolean) => void-Callback fired when the checked state changes.
disabledbooleanfalseIf true, the checkbox is disabled.
requiredbooleanfalseIf true, the checkbox is required.
namestring-The name attribute for form submission.
valuestring-The value attribute for form submission.
idstring-The id attribute for the checkbox.
classNamestring-Additional CSS classes.

Features

Accessibility

  • Full keyboard navigation support (Space to toggle)
  • Screen reader compatible with proper ARIA attributes
  • Focus management and visible focus indicators
  • Support for required and disabled states

States

  • Checked - Selected state
  • Unchecked - Default unselected state
  • Indeterminate - Partially selected state (useful for "select all" scenarios)
  • Disabled - Non-interactive state

Form Integration

  • Works with form libraries and native forms
  • Proper name/value attributes for form submission
  • Validation support with required attribute

Common Use Cases

The Checkbox component is perfect for:

  • Terms and conditions - User agreement checkboxes
  • Settings panels - Enable/disable features
  • Multi-select lists - Select multiple items from a list
  • Filters - Apply multiple filter criteria
  • Permissions - Grant/revoke access rights
  • Preferences - User preference selections
  • Bulk actions - Select all/none functionality

Best Practices

  1. Always provide labels - Use proper label elements for accessibility
  2. Group related options - Use fieldsets for checkbox groups
  3. Clear descriptions - Make checkbox purposes obvious
  4. Logical ordering - Order options in a meaningful way
  5. Validate appropriately - Mark required checkboxes clearly
  6. Handle indeterminate state - Use for parent/child relationships
  7. Test with keyboard - Ensure full keyboard accessibility