Checkbox

Turns one option on or off, or shows a mix for a group. Built on ui-sdk's Checkbox: Space toggles it, it submits with its form, and a parent checkbox controls its group. Sm (14 px) in forms, md (16 px) in task lists.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Checkbox, CheckboxGroup } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

size
label
defaultChecked
disabled

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoName every checkbox with a Label pointing at its id, a wrapping <label>, or aria-label. Pressing a label toggles the box, which makes the target larger.
DoUse a parent checkbox in a CheckboxGroup for select all. It shows indeterminate while only some are checked.
DoKeep the checkbox at the start of a list or table row, with md in task lists and sm in forms. Only a menu's selection tick sits on the right.
DoMark an invalid box with aria-invalid and say what to do in text near it, like Please confirm the conflict check. The red edge alone is colour alone.
Don'tUse a checkbox for a setting that takes effect at once. Use Switch; a checkbox waits for its form to be saved.
Don'tUse checkboxes for options where only one can be true, like how a matter is billed. Use RadioGroup.

Props

Both also take ui-sdk's props: checked, defaultChecked, onCheckedChange, disabled, readOnly, required, name, value, form and parent on Checkbox; value, defaultValue, onValueChange, allValues and name on CheckboxGroup.

Checkbox

PropTypeDefaultDescription
size"sm" | "md""sm"sm (14 px) in forms, md (16 px) in task lists.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

CheckboxGroup

PropTypeDefaultDescription
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { Checkbox, Label } from "@leap-crm/design-system";

<div className="flex items-center gap-2">
  <Checkbox id="email" />
  <Label htmlFor="email">Prefers email</Label>
</div>

With a label

Name each checkbox with a Label pointing at its id. Pressing the label toggles the box.

Group with select all

A parent checkbox checks or clears the group, and shows indeterminate when only some are checked.

Task list

The md size, for ticking tasks off a list.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { Fragment, type ReactNode } from "react";

import { Checkbox, CheckboxGroup, Label } from "@leap-crm/design-system";

const sizes = ["sm", "md"] as const;

const states = [
  "Unchecked",
  "Checked",
  "Indeterminate",
  "Invalid",
  "Disabled",
  "Disabled checked",
] as const;

function Row({ children }: { children: ReactNode }) {
  return <div className="text-body flex items-center gap-2">{children}</div>;
}

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
SpaceToggles it.
EnterSubmits the form, and never toggles it.
TabMoves through checkboxes in order.