Search documentation

Search the documentation and open a page.

A control that allows the user to toggle between checked and unchecked states.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/checkbox

Composition

Checkbox └── label content CheckboxRoot (custom composition) ├── CheckboxControl │ └── CheckboxIndicator ├── CheckboxLabel └── CheckboxHiddenInput

Examples

Choice Cards

Loading...

Default

Loading...

Group

Loading...

Invalid

Loading...

Nested

Loading...

Table Rows

Loading...

API Reference

Checkbox

PropTypeDefaultDescription
idstring | undefined—Unique identifier used to connect the component parts.
idsElementIds | undefined—Overrides generated identifiers for individual parts.
disabledboolean | undefinedfalseDisables interaction with the component.
invalidboolean | undefined—Marks the associated form control as invalid.
requiredboolean | undefinedfalseMarks the associated form control as required.
checkedCheckedState | undefined—Checked state when the component is controlled.
defaultCheckedCheckedState | undefined—Initial checked state when the component is uncontrolled.
readOnlyboolean | undefinedfalsePrevents changes while preserving focus and navigation.
onCheckedChange((details: CheckedChangeDetails) => void) | undefined—Runs when checked changes.
namestring | undefined—Name used when submitting the value with a form.
formstring | undefined—Associates the control with a form by ID.
valuestring | undefined—Current value when the component is controlled.

Context, Hooks, and Types

ExportAPI
CheckboxContextRender-prop component that exposes component state and actions.
CheckboxRootProviderProvides an externally created API to the component tree.
useCheckboxCreates or accesses the component API.
useCheckboxContextReturns the nearest component API.
CheckboxCheckedChangeDetailsType for the details object passed to the matching change callback.