Skip to main content

Overview

Checkbox provides a binary or tristate control that users can check or uncheck. It supports an indeterminate state for partial selections and can be used in forms or as a standalone control.

Features

  • Supports indeterminate state
  • Can be controlled or uncontrolled
  • Full keyboard navigation
  • Works inside forms
  • Accessible by default with proper ARIA attributes
  • Custom styling with data attributes

Installation

Anatomy

API Reference

Root

Contains all the checkbox component parts. An input will also render when used within a form to ensure events propagate correctly.
boolean | 'indeterminate'
The controlled checked state of the checkbox.
boolean | 'indeterminate'
The checked state when initially rendered (uncontrolled).
(checked: boolean | 'indeterminate') => void
Event handler called when the checked state changes.
boolean
When true, prevents the user from interacting with the checkbox.
boolean
When true, indicates that the user must check the checkbox before submitting the form.
string
The name of the checkbox. Submitted with its owning form as part of a name/value pair.
string
default:"'on'"
The value given as data when submitted with a name.
boolean
default:"false"
Change the default rendered element for the one passed as a child.

Indicator

Renders when the checkbox is in a checked or indeterminate state. You can style this element directly, or you can use it as a wrapper to put an icon into, or both.
boolean
Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
boolean
default:"false"
Change the default rendered element for the one passed as a child.

Example

Accessibility

Keyboard Interactions

  • Space - Toggles the checkbox.

Data Attributes

Root
  • [data-state] - “checked”, “unchecked”, or “indeterminate”
  • [data-disabled] - Present when disabled
Indicator
  • [data-state] - “checked”, “unchecked”, or “indeterminate”
  • [data-disabled] - Present when disabled