Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.
Checkbox
A control that allows the user to toggle between checked and not checked.
Features
Supports indeterminate state.
Full keyboard navigation.
Can be controlled or uncontrolled.
Anatomy
Import all parts and piece them together.
API Reference
Root
Contains all the parts of a checkbox. An input will also render when used within a form to ensure events propagate correctly.
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.
Examples
Indeterminate
You can set the checkbox to indeterminate by taking control of its state.
Decoupling the hidden input
By default, Checkbox.Root renders a visually hidden input for form submission. To recompose, move, or exclude that input, you can build the checkbox from its lower-level parts instead.
Important: These parts are unstable and prefixed with
unstable_, so their API may change in a future release.
Checkbox.unstable_Providerprovides the checkbox state and accepts the form-related props (name,value,checked,defaultChecked,required,disabled,onCheckedChange).Checkbox.unstable_Triggeris the interactive button that wrapsCheckbox.Indicator.Checkbox.unstable_BubbleInputis the visually hidden input thatCheckbox.Rootrenders by default. Omit it when you don't need form submission.
Accessibility
Adheres to the tri-state Checkbox WAI-ARIA design pattern.