Checkbox
Capture an independent checked, unchecked, or mixed choice.
Use Checkbox for an independent boolean or mapped choice that can be selected alongside other choices. Use Switch when the control represents an immediate on/off setting.
Basic usage#
Playground#
I agree to the privacy policy and terms of service.
Anatomy#
Usage#
State and form values#
Use checked with onCheckedChange for controlled state, or defaultChecked for an initial value.
Set indeterminate from aggregate selection state; it changes the mixed presentation without
adding a third submitted value.
trueValue and falseValue map checked state to domain values for callbacks and schema-bound
forms. Native form submission uses the separate value prop only while checked; an unchecked
checkbox contributes no entry.
Read-only and disabled#
disabled removes the control from normal interaction. readOnly preserves the value and focusability while preventing changes.
Examples#
Indeterminate and custom indicator#
Custom true and false values#
Form integration#
Attributes#
data-checkedSlot: checkbox, checkbox-control, checkbox-indicatorDescription: Present when the item or toggle is checked.data-disabledSlot: checkbox, checkbox-control, checkbox-indicatorDescription: Present when the component, slot, or item is disabled.data-indeterminateSlot: checkbox, checkbox-control, checkbox-indicatorDescription: Present when the checkbox or progress state is indeterminate.data-invalidSlot: checkbox, checkbox-controlDescription: Present when the field or form has a validation error.data-readonlySlot: checkbox, checkbox-controlDescription: Present when the field is in read-only mode.data-requiredSlot: checkbox, checkbox-control, checkbox-labelDescription: Present when the field input is required.data-uncheckedSlot: checkbox, checkbox-controlDescription: Present when the checkbox, radio item, or switch is unchecked.Props#
Props for the Checkbox component. Renders a <div> element by default.