tigran tumasov

Checkbox

Forms 79

About

A control that toggles between two options, checked or unchecked.

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 React, { useState } from "react";
import { Checkbox } from "@/components/ui/checkbox";

export const Demo = () => {
  const [checked, setChecked] = useState(false);

  return (
    <div className="flex flex-col gap-8">
      <div className="flex flex-col gap-2">
        <div className="font-bold text-xl dark:text-white">Default</div>
        <Checkbox checked={checked} onChange={(): void => setChecked((value) => !value)}>
          Option 1
        </Checkbox>
      </div>
      <div className="flex flex-col gap-2">
        <div className="font-bold text-xl dark:text-white">Disabled</div>
        <Checkbox disabled>Disabled</Checkbox>
        <Checkbox checked disabled>
          Disabled Checked
        </Checkbox>
        <Checkbox disabled indeterminate>
          Disabled Indeterminate
        </Checkbox>
      </div>
      <div className="flex flex-col gap-2">
        <div className="font-bold text-xl dark:text-white">Indeterminate</div>
        <Checkbox indeterminate>Option 1</Checkbox>
      </div>
    </div>
  );
};

export const Default = () => {
  const [checked, setChecked] = useState(false);

  return (
    <div className="flex flex-col gap-8">
      <div className="flex flex-col gap-2">
        <div className="font-bold text-xl dark:text-white">Default</div>
        <Checkbox checked={checked} onChange={(): void => setChecked((b) => !b)}>
          Option 1
        </Checkbox>
      </div>
    </div>
  )
}

export const Disabled = () => (
  <div className="flex flex-col gap-8">
    <div className="flex flex-col gap-2">
        <div className="font-bold text-xl dark:text-white">Disabled</div>
        <Checkbox disabled>Disabled</Checkbox>
        <Checkbox checked disabled>
          Disabled Checked
        </Checkbox>
        <Checkbox disabled indeterminate>
          Disabled Indeterminate
        </Checkbox>
      </div>
  </div>
)

export const Indeterminate = () => (
  <div className="flex flex-col gap-8">
    <div className="flex flex-col gap-2">
      <div className="font-bold text-xl dark:text-white">Indeterminate</div>
      <Checkbox indeterminate>Option 1</Checkbox>
    </div>
  </div>
)

More by tigran tumasov

View all
  • Product Hunt Badge

    Product Hunt Badge

    2K
  • Book

    Book

    189
  • Calendar

    Calendar

    157
  • Theme Switcher

    Theme Switcher

    143
  • Table

    Table

    125
  • Snippet

    Snippet

    125
  • Toggle

    Toggle

    101
  • Feedback

    Feedback

    95

More in Forms

View all
  • Premium Auth

    Premium Auth

    593
  • Contact Form

    Contact Form

    28
  • Form

    Form

    4
  • Login 1

    Login 1

    70
  • Book A Demo 1

    Book A Demo 1

    94
  • Contact Card

    Contact Card

    1.1K
  • HeroUI Field Error

    HeroUI Field Error

    13
  • Form [react-aria-components]

    Form [react-aria-components]

    19