robertlib

Checkbox

Forms 1

About

A checkbox form control with a label and optional description that works controlled or uncontrolled, and supports an indeterminate (partly checked) and a read-only state like a native checkbox.

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

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

export default function Basic() {
  const [accepted, setAccepted] = useState(false);

  return (
    <div className="space-y-4">
      <Checkbox
        defaultChecked
        label="Send me a weekly summary"
        name="summary"
      />
      <Checkbox
        description="We only use it to answer your questions."
        label="Allow contacting me by email"
        name="contact"
      />
      <Checkbox
        checked={accepted}
        error={accepted ? undefined : "You have to accept the terms."}
        label="I accept the terms"
        onChange={(event) => setAccepted(event.target.checked)}
        required
      />
      <Checkbox disabled label="Disabled" />
    </div>
  );
}

More by robertlib

View all
  • Timeline

    Timeline

    13
  • Spinner

    Spinner

    5
  • Switch

    Switch

    4
  • Collapsible Content

    Collapsible Content

    3
  • Chip

    Chip

    2
  • Empty State

    Empty State

    2
  • Progress Indicator

    Progress Indicator

    1
  • Avatar

    Avatar

More in Forms

View all
  • Authentication Card

    Authentication Card

    51
  • Contact Card

    Contact Card

    1.1K
  • Premium Auth

    Premium Auth

    560
  • Book A Demo 1

    Book A Demo 1

    88
  • Modern & Stunning sign in

    Modern & Stunning sign in

    1.7K
  • Card Studio

    Card Studio

    46
  • SignInPage

    SignInPage

    741
  • Form

    Form

    139