Skip to main content

Checkbox

import { Checkbox } from "@study/ui"

The round box for ticking off. With strike, a finished task is crossed out.

Result
Loading...
Live Editor
function Example() {
  const [tasks, setTasks] = useState([
    { title: "Read script chapter 3", done: true },
    { title: "Do exercise sheet 4", done: false },
  ]);
  return (
    <div>
      {tasks.map((t, i) => (
        <Checkbox key={t.title} label={t.title} strike checked={t.done} tone="gruen"
          onChange={() => setTasks(tasks.map((x, j) => (j === i ? { ...x, done: !x.done } : x)))} />
      ))}
    </div>
  );
}

Variants and states​

Light

Dark

When to use​

✓ DoTicking off tasks; agreements in a form that is saved later.
✗ Don'tA setting that applies at once – that is a Switch.

Props​

Plus all attributes of an <input type="checkbox">.

PropTypeDefaultMeaning
label *ReactNode–
descriptionReactNode–A second, quieter line.
hideLabelboolean–Hides the label from the eye, e.g. when the task's title stands next to the box.
refRef<HTMLInputElement>–
strikeboolean–Strikes the label through when checked, as for a done task.
tone"blau" | "petrol" | "gruen" | "gelb" | "orange" | "rot" | "violett" | "grau"–The colour of the checked box; default the dark ink.

Accessibility​

  • A real checkbox under the box: Space ticks it, screen readers say "checked".
  • The whole row is clickable and at least 44 px high.