Wensity Labs

Checkbox

Forms

About

An animated checkbox with a drawn check mark, an indeterminate state for select all, labels and descriptions, and classic or soft styles. Themed with shadcn tokens.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Checkbox to your project and fits it to your theme.

Code

How Checkbox is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";
import { Checkbox, type CheckboxCheckedState } from "@/components/ui/checkbox";

const settings = {
  variant: "classic",
  checkboxSize: "md",
};

const TASKS = [
  { id: "design", label: "Review the design spec", description: "Figma file shared by the product team." },
  { id: "api", label: "Wire up the billing API", description: "Webhooks and retry logic." },
  { id: "qa", label: "QA on mobile Safari", description: "Focus on the checkout flow." },
];

export default function CheckboxDemo(props: Partial<typeof settings>) {
  const s = { ...settings, ...props };
  const variant = s.variant as "classic" | "soft";
  const size = s.checkboxSize as "sm" | "md" | "lg";
  const [done, setDone] = React.useState<Record<string, boolean>>({ design: true });

  const count = TASKS.filter((t) => done[t.id]).length;
  const all: CheckboxCheckedState =
    count === TASKS.length ? true : count === 0 ? false : "indeterminate";

  return (
    <div className="flex min-h-[420px] w-full items-center justify-center bg-background p-6">
      <div className="w-full max-w-md rounded-xl border border-border bg-card p-6 text-card-foreground shadow-sm">
        <div className="flex items-center justify-between border-b border-border pb-4">
          <Checkbox
            variant={variant}
            checkboxSize={size}
            checked={all}
            onCheckedChange={(next) =>
              setDone(Object.fromEntries(TASKS.map((t) => [t.id, next === true])))
            }
            label="Sprint checklist"
            fullWidth={false}
          />
          <span className="shrink-0 whitespace-nowrap text-xs text-muted-foreground">
            {count} of {TASKS.length} done
          </span>
        </div>
        <div className="space-y-4 pt-4">
          {TASKS.map((task) => (
            <Checkbox
              key={task.id}
              variant={variant}
              checkboxSize={size}
              checked={!!done[task.id]}
              onCheckedChange={(next) => setDone((d) => ({ ...d, [task.id]: next === true }))}
              label={task.label}
              description={task.description}
            />
          ))}
        </div>
      </div>
    </div>
  );
}

Dependencies

More by Wensity Labs

View all
  • Sidebar

    Sidebar

    444
  • Calendar

    Calendar

    343
  • Button

    Button

    169
  • Color Picker

    Color Picker

    114
  • Image Comparison Slider

    Image Comparison Slider

    92
  • AI Prompt Input

    AI Prompt Input

    88
  • Text Morphing

    Text Morphing

    69
  • Carousel

    Carousel

    65

More in Forms

View all
  • Form

    Form

    7
  • Login 2

    Login 2

    16
  • Contact Form

    Contact Form

    33
  • Contact Card

    Contact Card

    1.1K
  • Book A Demo 1

    Book A Demo 1

    95
  • Premium Auth

    Premium Auth

    613
  • Onboarding Stepper

    Onboarding Stepper

    13
  • Authentication Card

    Authentication Card

    52