// preview in
saved for every page

Checkbox

Turns one option on or off, or picks any number from a list. CheckboxGroup holds the values as an array and can drive a "select all" box.

Built on Base UIPattern WAI-ARIA CheckboxClient componentSource ↗
minimal · light · #3fa34d
defaultChecked
indeterminate
disabled

Installation

Set up Camaleo once (Installation), then import what you need. Wrap each checkbox in a Label so the text is clickable and names it.

import { Checkbox, CheckboxGroup, Label } from "@camaleo/react";

Anatomy

A Checkbox is a box with an indicator inside. A CheckboxGroup wraps several labeled checkboxes and keeps their values together.

checkboxProduct updates
[data-slot="checkbox-group"][data-slot="checkbox"] · [data-slot="checkbox-indicator"][data-slot="label"] text

Examples

Every example is a real file you can copy. They all wear the skin, mode and brand from the bar above.

minimal · light · #3fa34d
Email me about

A group with a legend

Fieldset render={<CheckboxGroup />} gives the options one name, so a screen reader announces "Email me about" before each of them.

Columns to export

2 of 4 columns selected

Select all

Click the children. With allValues on the group and parent on one box, it shows the mixed state when only some are ticked.

Refunds over $500 wait for an admin to approve them.

With a description

Keep the label short and put the consequence below it, linked with aria-describedby so it is read after the name.

Required, with an error

Submit it unticked. Say what to do in the error, not just "Required"; Field links it to the checkbox.

Available on the Business plan.

Disabled, with a reason

A disabled box still shows what is included. When it is off, say why, so people know how to get it.

SelectInvoiceClientAmount
#1042Northwind Traders$1,280.00
#1043Lumen Studio$640.50
#1044Atlas Freight$3,915.00

Row selection

In a table the row is the label, so give each checkbox an aria-label that names its row.

In context

Checkboxes live in forms and lists. These are whole pieces of UI you can copy, in the skin you picked.

Create your account

Free for 14 days. No card needed.

Signup with termsCard · Field · Input · Checkbox · Button

Filters

Brand
Availability
Filter panelCard · Fieldset · CheckboxGroup · Separator

Launch checklist

2 of 5 done

ChecklistCard · CheckboxGroup · Checkbox

Guidelines

Notify me by
DoCheckboxes for any number of options.

Each one stands alone: people can pick none, one or all of them.

Billing period
Don’tCheckboxes for options that exclude each other.

Monthly and yearly at once makes no sense. Use a RadioGroup.

DoSay what a tick turns on.

A ticked box should mean yes: "Send me the weekly digest".

Don’tNegative labels.

A tick that means "don't stop" makes people stop and reread.

Props

PropTypeDefaultDescription
namestringundefinedIdentifies the field when a form is submitted.
checkedbooleanundefinedWhether the checkbox is currently ticked. To render an uncontrolled checkbox, use the defaultChecked prop instead.
defaultCheckedbooleanfalseWhether the checkbox is initially ticked. To render a controlled checkbox, use the checked prop instead.
disabledbooleanfalseWhether the component should ignore user interaction.
onCheckedChange(checked: boolean, details) => void—Event handler called when the checkbox is ticked or unticked.
readOnlybooleanfalseWhether the user should be unable to tick or untick the checkbox.
requiredbooleanfalseWhether the user must tick the checkbox before submitting a form.
indeterminatebooleanfalseWhether the checkbox is in a mixed state: neither ticked, nor unticked.
parentbooleanfalseWhether the checkbox controls the children of a CheckboxGroup (the "select all" box).
valuestring—Identifies the checkbox inside a CheckboxGroup and is the value submitted with the form.

CheckboxGroup takes value, defaultValue and onValueChange (arrays of the checkboxes' value), allValues for a parent checkbox, and disabled. Native attributes pass through.

Styling hooks

Restyle it without forking: target the attributes, or set the tokens on a parent, a skin or the checkbox itself.

Attributes

data-slot"checkbox" · "checkbox-indicator" · "checkbox-group"
data-checkedpresent when ticked
data-uncheckedpresent when not ticked
data-indeterminatepresent in the mixed state
data-disabledpresent when disabled
data-invalidpresent when its Field is invalid

Tokens it reads

Color

--cml-accent--cml-accent-fg--cml-border-control--cml-field-bg--cml-focus-offset--cml-focus-ring--cml-focus-width

Shape & size

--cml-font-size-field--cml-gap--cml-radius-check

Type & motion

--cml-duration-fast--cml-ease-standard--cml-font-body

This component only

--cml-check-border-width--cml-check-on-border--cml-check-on-image--cml-check-on-shadow--cml-check-shadow--cml-check-size--cml-corner-shape--cml-disabled-opacity

Accessibility

SpaceTicks or unticks the focused checkbox.
TabMoves to the next checkbox; each one is its own tab stop.
Was this page helpful? · Edit this page on GitHub