Skip to content
HomeCobalt

Checkbox

One choice that is on or off, or stands for a set that is partly on, and takes effect when the form is saved.

Examples

A set of choices under one legend, each box inside its label, sent when the form is saved.
Email me when

In a labelThe whole row toggles the box, and the ticked columns go into the file when it is downloaded.
Columns in the file

States

DisabledOff and on at half opacity, the label faded too, each saying why it cannot change.

Sends to 14 people.

IndeterminateMixed while some rows are checked; it selects or clears all.
Agree to the cancellation policy to book the room.
InvalidA red edge on the box and the error under it, as after a submit without it, until the box is ticked.

Usage

Use it when

  • You turn one option on or off and the change applies when the form is saved.
  • You pick any number of items from a list: filters, lists to send to, rows to act on.
  • One box stands for a set of rows and must say "some" as well as "all" and "none".

Use something else when

  • The setting applies the moment it flips. Use Switch instead.
  • Exactly one of a few options may be chosen. Use SegmentedControl instead, or Select past 4 options.
  • The on state is a filter chip in a row of chips. Use Pill instead.
  • A list of rows a person selects to act on together. Use DataTable instead, with selection and DataTableToolbar.

Rules

General

Content

Avoid

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/checkbox.json
import { Checkbox } from "@/components/cobalt/ui/checkbox"