Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
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
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
ids | ElementIds | undefined | — | Overrides generated identifiers for individual parts. |
disabled | boolean | undefined | false | Disables interaction with the component. |
invalid | boolean | undefined | — | Marks the associated form control as invalid. |
required | boolean | undefined | false | Marks the associated form control as required. |
checked | CheckedState | undefined | — | Checked state when the component is controlled. |
defaultChecked | CheckedState | undefined | — | Initial checked state when the component is uncontrolled. |
readOnly | boolean | undefined | false | Prevents changes while preserving focus and navigation. |
onCheckedChange | ((details: CheckedChangeDetails) => void) | undefined | — | Runs when checked changes. |
name | string | undefined | — | Name used when submitting the value with a form. |
form | string | undefined | — | Associates the control with a form by ID. |
value | string | undefined | — | Current value when the component is controlled. |
Context, Hooks, and Types
| Export | API |
|---|---|
CheckboxContext | Render-prop component that exposes component state and actions. |
CheckboxRootProvider | Provides an externally created API to the component tree. |
useCheckbox | Creates or accesses the component API. |
useCheckboxContext | Returns the nearest component API. |
CheckboxCheckedChangeDetails | Type for the details object passed to the matching change callback. |
Angular
React
Solid
Svelte
Vue