Checkbox

Checkboxes with a draw-on checkmark and an indeterminate state.

Checkbox

checkbox.tsx
"use client";

import { useState } from "react";
import { Checkbox } from "@/components/motion/checkbox";

export function CheckboxPreview() {
  const [terms, setTerms] = useState(true);
  const [updates, setUpdates] = useState(false);

  return (
    <div className="flex flex-col gap-3">
      <Checkbox
        checked={terms}
        onCheckedChange={setTerms}
        label="Accept terms and conditions"
      />
      <Checkbox
        checked={updates}
        onCheckedChange={setUpdates}
        label="Email me product updates"
      />
      <Checkbox checked indeterminate onCheckedChange={() => {}} label="Select all (partial)" />
      <Checkbox checked disabled onCheckedChange={() => {}} label="Disabled" />
    </div>
  );
}

With Description

checkbox.tsx
"use client";

import { useState } from "react";
import { Checkbox } from "@/components/motion/checkbox";

export function CheckboxDescriptionPreview() {
  const [comments, setComments] = useState(true);
  const [mentions, setMentions] = useState(true);
  const [digest, setDigest] = useState(false);

  return (
    <div className="flex w-full max-w-64 flex-col gap-3">
      <Checkbox
        checked={comments}
        onCheckedChange={setComments}
        label="Comments"
        description="Replies on threads you started."
      />
      <Checkbox
        checked={mentions}
        onCheckedChange={setMentions}
        label="Mentions"
        description="Whenever someone tags you by name."
      />
      <Checkbox
        checked={digest}
        onCheckedChange={setDigest}
        label="Weekly digest"
        description="A summary of activity every Monday."
      />
      <Checkbox
        checked={false}
        disabled
        onCheckedChange={() => {}}
        label="SMS alerts"
        description="Add a phone number to enable."
      />
    </div>
  );
}

API Reference

checked
boolean

Whether the box is checked.

onCheckedChange
(checked: boolean) => void

Called with the new state when the box is toggled.

disabled?
boolean

Blocks toggling and dims the control.

indeterminate?
boolean

Shows a dash for a partly selected group. Announced as mixed.

label?
string

Visible text beside the box, also its accessible name.

description?
string

Supporting text under the label, announced as the description rather than the name.

className?
string

Classes merged onto the root label element.

id?
string

Id for the checkbox button. Generated when omitted.

aria-label?
string

Accessible name when there is no visible label.

aria-describedby?
string

Associates an external message (e.g. a form error) with the control.

labels?
Partial<{ checked: string; indeterminate: string; }>

Override any built-in string.

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/checkbox
Also on React Native. A checkmark that draws itself in.

Updated