Checkbox

Anatomy

States

Default · Unchecked

Default · Checked

Default · Indeterminate

Hover · Unchecked

Hover · Checked

Hover · Indeterminate

Pressed · Unchecked

Pressed · Checked

Pressed · Indeterminate

Focus · Unchecked

Focus · Checked

Focus · Indeterminate

Disabled · Unchecked

Disabled · Checked

Disabled · Indeterminate

Invalid

Invalid + focus

Content

Themes

Light

Dark

Primary override

Example

Include in export

IncludedImages, Notes

Team members
NameEmailRole
Sarah Chen[email protected]Admin
Marcus Rodriguez[email protected]User
Priya Patel[email protected]User
David Kim[email protected]Editor
View code
"use client";

import { Checkbox } from "@baseline/ui";
import { useState } from "react";

const options = ["Images", "Captions", "Notes"] as const;

export function ExportSelectionExample() {
  const [selected, setSelected] = useState<ReadonlySet<string>>(() => new Set(["Images", "Notes"]));

  return (
    <div>
      <fieldset className="bl-choice-list">
        <legend>Include in export</legend>
        {options.map((option) => (
          <label className="bl-choice" key={option}>
            <Checkbox
              checked={selected.has(option)}
              name="exportItems"
              onChange={(event) => {
                const next = new Set(selected);
                if (event.currentTarget.checked) next.add(option);
                else next.delete(option);
                setSelected(next);
              }}
              value={option.toLowerCase()}
            />
            <span className="bl-choice__label">{option}</span>
          </label>
        ))}
      </fieldset>
      <p aria-live="polite">
        Included: {options.filter((option) => selected.has(option)).join(", ") || "Nothing"}
      </p>
    </div>
  );
}