konicamaheshwarii

Checkbox

Forms

About

A checkbox input with support for an indeterminate "mixed" state, an optional hint line, and disabled state — ported from the ngx-aurora-ui Angular library's au-checkbox by Konica Maheshwari (MIT).

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 * as React from "react";

export default function CheckboxDemo() {
  const [items, setItems] = React.useState([
    { label: "Mentions", checked: true },
    { label: "Replies", checked: false },
    { label: "Weekly digest", checked: false },
  ]);

  const checkedCount = items.filter((i) => i.checked).length;
  const allState =
    checkedCount === 0
      ? "none"
      : checkedCount === items.length
        ? "all"
        : "some";

  function toggle(index, checked) {
    setItems((list) =>
      list.map((item, i) => (i === index ? { ...item, checked } : item)),
    );
  }

  function setAll(checked) {
    setItems((list) => list.map((item) => ({ ...item, checked })));
  }

  return (
    <div className="w-full max-w-sm rounded-lg border p-4">
      <fieldset className="m-0 border-0 flex flex-col gap-3">
        <legend className="px-1 text-sm font-medium">Notifications</legend>
        <Checkbox
          checked={allState === "all"}
          indeterminate={allState === "some"}
          onCheckedChange={setAll}
        >
          All notifications
        </Checkbox>
        <div className="flex flex-col gap-2.5 pl-7">
          {items.map((item, i) => (
            <Checkbox
              key={item.label}
              checked={item.checked}
              onCheckedChange={(v) => toggle(i, v)}
            >
              {item.label}
            </Checkbox>
          ))}
        </div>
      </fieldset>
    </div>
  );
}

More by konicamaheshwarii

View all
  • Tooltip

    Tooltip

  • Aurora Switch

    Aurora Switch

  • Skeleton Loader

    Skeleton Loader

  • Aurora Dialog

    Aurora Dialog

  • Aurora Badge

    Aurora Badge

More in Forms

View all
  • Premium Auth

    Premium Auth

    592
  • Login 1

    Login 1

    70
  • Contact Card

    Contact Card

    1.1K
  • Contact Form

    Contact Form

    28
  • Form

    Form

    6
  • HeroUI Field Error

    HeroUI Field Error

    13
  • Form

    Form

    4
  • Book A Demo 4

    Book A Demo 4

    69