Installation
Add Component
Copy the code snippet below into you components folder.
Integrate Recipe
Integrate this recipe in to your Panda config.
Usage
If you prefer a closed component composition, check out the snippet below.
Examples
Variants
Customize the appearance with different visual styles to match your design:
Colors
Use the colorPalette prop to change the color of the checkbox:
Sizes
Adjust the size to match surrounding text or interface elements:
States
Pass the disabled or invalid prop to the Checkbox.Root component to change the visual state of the checkbox.
Controlled
Use the checked and onCheckedChange props to control the checkbox state.
Label
Here's an example of how to change the label position to the left:
Indeterminate
Set the checked prop to indeterminate to show the checkbox in an indeterminate state.
Description
Here's an example of how to add some further description to the checkbox:
Link
Render an anchor tag within the Checkbox.Label to add a link to the label.
Closed Component
Here's how to setup the avatar for a closed component composition.
To use the closed component, simply import and use it like this:
Props
Root
| Prop | Default | Type | 
|---|---|---|
| size | 'md' | 'sm' | 'md' | 'lg' | 
| variant | 'solid' | 'solid' | 'surface' | 'subtle' | 'outline' | 'plain' | 
| value | \on\ | stringThe value of checkbox input. Useful for form submission. | 
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| checked | CheckedStateThe controlled checked state of the checkbox | |
| defaultChecked | CheckedStateThe initial checked state of the checkbox when rendered. Use when you don't need to control the checked state of the checkbox. | |
| disabled | booleanWhether the checkbox is disabled | |
| form | stringThe id of the form that the checkbox belongs to. | |
| id | stringThe unique identifier of the machine. | |
| ids | Partial<{ root: string; hiddenInput: string; control: string; label: string }>The ids of the elements in the checkbox. Useful for composition. | |
| invalid | booleanWhether the checkbox is invalid | |
| name | stringThe name of the input field in a checkbox. Useful for form submission. | |
| onCheckedChange | (details: CheckedChangeDetails) => voidThe callback invoked when the checked state changes. | |
| readOnly | booleanWhether the checkbox is read-only | |
| required | booleanWhether the checkbox is required | 
Group
| Prop | Default | Type | 
|---|---|---|
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| defaultValue | string[]The initial value of `value` when uncontrolled | |
| disabled | booleanIf `true`, the checkbox group is disabled | |
| invalid | booleanIf `true`, the checkbox group is invalid | |
| name | stringThe name of the input fields in the checkbox group (Useful for form submission). | |
| onValueChange | (value: string[]) => voidThe callback to call when the value changes | |
| readOnly | booleanIf `true`, the checkbox group is read-only | |
| value | string[]The controlled value of the checkbox group | 
GroupProvider
| Prop | Default | Type | 
|---|---|---|
| value* | UseCheckboxGroupContext | |
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | 
Indicator
| Prop | Default | Type | 
|---|---|---|
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| indeterminate | boolean |