Search

Find a component, token or page

Base · Forms

Checkbox

Selects one or more options, or agrees to a statement.

HTML / JSDraftReactStableReact NativeDraftSwift (SwiftUI)PlannedGodotPlannedVueDraftSvelteDraftSolidDraft
Reviewed

Props

tsx
import { Checkbox } from "@/components/ui/checkbox"
import { Label } from "@/components/ui/label"

<Label>
  <Checkbox />
  Email me shipment updates
</Label>

React: Uncontrolled by default: pass `defaultChecked`, or `checked` with `onCheckedChange` to control it.

Overview

A checkbox is an independent on or off choice that takes effect when the form is submitted. Use a group of them when people can pick any number of options.

When to use

  • To pick any number of options from a list.
  • For a single agreement, such as accepting terms.
  • When the choice is applied later, on submit.

When not to use

  • For a setting that takes effect immediately: use Switch.
  • When only one option can be chosen: use Radio Group.

Anatomy

  1. Box

    A 16px square. Filled with the brand color when checked.

  2. Check mark

    Drawn in the on-solid color for contrast.

  3. Label

    Clicking it toggles the box. Written as a statement, not a question.

Props

The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).

PropTypeDefaultDescription
checkedbooleanfalseWhether the box is checked.
disabledbooleanfalsePrevents interaction and dims the control.
labelstringEmail me shipment updatesThe text next to the box.
onCheckedChangefunction–Called with the new checked state. `onchange` in Dioxus.

States

Unchecked
Empty box with an input-colored border.
Checked
Brand fill with a check mark.
Focus-visible
3px ring in color.border.focus.
Disabled
50% opacity; not focusable.

Accessibility

Role: checkbox

KeysAction
SpaceToggles the checkbox.
TabMoves focus to the next control.
  • The label must be programmatically tied to the box so its whole area is clickable.
  • Group related checkboxes in a fieldset with a legend.

Design tokens

Change any of these in Foundations and this component follows, in every language.

Platform notes

HTML / JS
Draft
A native checkbox input styled by pdc.css: `checked` and `disabled` go on the <input>, and the wrapping <label> makes the whole row clickable. No script.
React
Stable
Uncontrolled by default: pass `defaultChecked`, or `checked` with `onCheckedChange` to control it.
React Native
Draft
Controlled: pass `checked` and `onCheckedChange`. The label is a prop so the whole row is one touch target.
Swift (SwiftUI)
Planned
Not built in Swift yet.
Godot
Planned
Not built in Godot yet.
Vue
Draft
Usage snippet only; Vue and Svelte bind state with v-model / bind:checked, otherwise same props and behavior as the React component.
Svelte
Draft
Usage snippet only; Vue and Svelte bind state with v-model / bind:checked, otherwise same props and behavior as the React component.
Solid
Draft
Usage snippet only; Vue and Svelte bind state with v-model / bind:checked, otherwise same props and behavior as the React component.

Related