Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsPlaygroundGuidesBlog
Sponsor

Checkbox

Used in forms when a user needs to select multiple values from several options

SourceStorybookRecipeArk

Setup

If you don't already have the snippet, run the following command to add the checkbox snippet

npx @chakra-ui/cli snippet add checkbox

The snippet includes a closed component composition for the Checkbox

Usage

import { Checkbox } from "@/components/ui/checkbox"
<Checkbox>Click me</Checkbox>

Examples

Variants

Use the variant prop to change the visual style of the checkbox.

outline

subtle

solid

Controlled

Use the checked and onCheckedChange props to control the state of the checkbox.

Colors

Use the colorPalette prop to change the color of the checkbox.

gray

red

green

blue

teal

pink

purple

cyan

orange

yellow

Sizes

Use the size prop to change the size of the checkbox.

States

Use the disabled or invalid prop to change the visual state of the checkbox.

Hook Form

Here's an example of how to use the Checkbox component with the react-hook-form library.

Checked: false

Group

Use the CheckboxGroup component to group multiple checkboxes together.

Select framework

Group Hook Form

Here's an example of how to use the CheckboxGroup component with the react-hook-form library.

Select your framework
Values: []

Custom Icon

Use the icon prop to change the icon of the checkbox.

Indeterminate

Set the checked prop to indeterminate to show the checkbox in an indeterminate state.

Description

Add content to the children of the Checkbox component to add a description.

Render an anchor tag as the checkbox label.

Without Snippet

If you don't want to use the snippet, you can use the Checkbox component from the @chakra-ui/react package.

Props

Root

PropDefaultType
value '\'on\''
string

The value of checkbox input. Useful for form submission.

colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | 'accent'

The color palette of the component

size 'md'
'sm' | 'md' | 'lg'

The size of the component

variant 'outline'
'outline' | 'subtle'

The variant of the component

asChild
boolean

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

For more details, read our Composition guide.
checked
CheckedState

The checked state of the checkbox

defaultChecked
CheckedState

The checked state of the checkbox when it is first rendered. Use this when you do not need to control the 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

as
React.ElementType

The underlying element to render.

unstyled
boolean

Whether to remove the component's style.

Previous

Checkbox Card

Next

Clipboard