Park UI

Checkbox

A form control for toggling between checked and unchecked states.

Installation

Usage

Info

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:

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

PropDefaultType
size'md'
'sm' | 'md' | 'lg'
variant'solid'
'solid' | 'surface' | 'subtle' | 'outline' | 'plain'
value\on\
string

The value of checkbox input. Useful for form submission.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

checked
CheckedState

The controlled checked state of the checkbox

defaultChecked
CheckedState

The initial checked state of the checkbox when rendered. Use when you don't need to control the checked state of the checkbox.

disabled
boolean

Whether the checkbox is disabled

form
string

The id of the form that the checkbox belongs to.

id
string

The 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
boolean

Whether the checkbox is invalid

name
string

The name of the input field in a checkbox. Useful for form submission.

onCheckedChange
(details: CheckedChangeDetails) => void

The callback invoked when the checked state changes.

readOnly
boolean

Whether the checkbox is read-only

required
boolean

Whether the checkbox is required

Group

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

defaultValue
string[]

The initial value of `value` when uncontrolled

disabled
boolean

If `true`, the checkbox group is disabled

invalid
boolean

If `true`, the checkbox group is invalid

name
string

The name of the input fields in the checkbox group (Useful for form submission).

onValueChange
(value: string[]) => void

The callback to call when the value changes

readOnly
boolean

If `true`, the checkbox group is read-only

value
string[]

The controlled value of the checkbox group

GroupProvider

PropDefaultType
value*
UseCheckboxGroupContext
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

Indicator

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

indeterminate
boolean