{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkbox-draw",
  "title": "Drawn checkbox",
  "description": "Checkbox whose check stroke draws itself in over a popping fill, with an indeterminate dash and an animated strike-through for checklists.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json"
  ],
  "files": [
    {
      "path": "registry/components/inputs/checkbox-draw.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { GooduiTokens, spring, ease as easing } from \"@/lib/goodui-motion\"\n\nexport type CheckboxDrawState = boolean | \"indeterminate\"\n\nconst SIZES = {\n  sm: { box: \"size-4 rounded-[4px]\", stroke: 2.6 },\n  md: { box: \"size-5 rounded-[5px]\", stroke: 2.3 },\n  lg: { box: \"size-6 rounded-md\", stroke: 2.1 },\n} as const\n\nexport type CheckboxDrawProps = Omit<React.ComponentProps<\"button\">, \"onChange\" | \"value\" | \"defaultChecked\"> & {\n  /** Controlled state: true, false or \"indeterminate\" (draws a dash, aria-checked=\"mixed\"). */\n  checked?: CheckboxDrawState\n  /** Initial state when uncontrolled; also accepts \"indeterminate\". */\n  defaultChecked?: CheckboxDrawState\n  /** Clicking an indeterminate box checks it. */\n  onCheckedChange?: (checked: boolean) => void\n  /** Box size: \"sm\" 16px, \"md\" 20px, \"lg\" 24px. */\n  size?: keyof typeof SIZES\n  /** Clickable label next to the box; also its accessible name. */\n  label?: React.ReactNode\n  /** Muted helper text under the label, linked with aria-describedby. */\n  description?: React.ReactNode\n  /** Draw a line through the label when checked (to-do lists). */\n  strikethrough?: boolean\n  /** Form field name; renders a hidden input that submits `value` when checked and \"\" when not. */\n  name?: string\n  /** Value submitted with `name` when checked. */\n  value?: string\n}\n\n/** Checkbox whose check mark draws itself in, with an indeterminate dash and an optional strike-through label. */\nexport function CheckboxDraw({\n  checked: checkedProp,\n  defaultChecked = false,\n  onCheckedChange,\n  size = \"md\",\n  label,\n  description,\n  strikethrough,\n  name,\n  value = \"on\",\n  disabled,\n  className,\n  id: idProp,\n  onClick,\n  ...props\n}: CheckboxDrawProps) {\n  const reduce = useReducedMotion() ?? false\n  const [inner, setInner] = React.useState<CheckboxDrawState>(defaultChecked)\n  const state = checkedProp ?? inner\n  const on = state === true\n  const mixed = state === \"indeterminate\"\n  const filled = on || mixed\n  const uid = React.useId()\n  const id = idProp ?? uid\n  const s = SIZES[size]\n\n  const draw = (show: boolean, delay = 0) =>\n    reduce\n      ? { duration: 0 }\n      : show\n        ? { pathLength: { duration: 0.24, delay, ease: easing.inOut }, opacity: { duration: 0.01, delay } }\n        : { pathLength: { duration: 0.12 }, opacity: { duration: 0.1, delay: 0.08 } }\n\n  const box = (\n    <button\n      type=\"button\"\n      role=\"checkbox\"\n      id={id}\n      aria-checked={mixed ? \"mixed\" : on}\n      aria-describedby={description ? `${id}-desc` : undefined}\n      data-state={mixed ? \"indeterminate\" : on ? \"checked\" : \"unchecked\"}\n      disabled={disabled}\n      onClick={(e) => {\n        const next = !on\n        if (checkedProp === undefined) setInner(next)\n        onCheckedChange?.(next)\n        onClick?.(e)\n      }}\n      className={cn(\n        \"pc-press group/cb relative inline-grid shrink-0 cursor-pointer place-items-center border border-input bg-background shadow-xs transition-[border-color,box-shadow] outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30\",\n        filled && \"border-primary\",\n        s.box,\n        className,\n      )}\n      {...props}\n    >\n      <motion.span\n        aria-hidden=\"true\"\n        className=\"absolute inset-[-1px] rounded-[inherit] bg-primary\"\n        initial={false}\n        animate={{ scale: filled ? 1 : reduce ? 1 : 0.4, opacity: filled ? 1 : 0 }}\n        transition={reduce ? { duration: 0 } : spring.play}\n      />\n      {/* Press squash in CSS: motion's whileTap would make this aria-hidden span focusable (tabindex=0). */}\n      <span\n        aria-hidden=\"true\"\n        className=\"relative grid size-full place-items-center transition-transform duration-200 ease-[var(--pc-ease-spring)] group-enabled/cb:group-active/cb:scale-[0.82] motion-reduce:transition-none motion-reduce:group-active/cb:scale-100\"\n      >\n        <svg viewBox=\"0 0 20 20\" fill=\"none\" className=\"size-full text-primary-foreground\">\n          <motion.path\n            d=\"M5 10.4 8.6 14 15.2 6.6\"\n            stroke=\"currentColor\"\n            strokeWidth={s.stroke}\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n            initial={false}\n            animate={{ pathLength: on ? 1 : 0, opacity: on ? 1 : 0 }}\n            transition={draw(on, 0.06)}\n          />\n          <motion.path\n            d=\"M5.5 10h9\"\n            stroke=\"currentColor\"\n            strokeWidth={s.stroke}\n            strokeLinecap=\"round\"\n            initial={false}\n            animate={{ pathLength: mixed ? 1 : 0, opacity: mixed ? 1 : 0 }}\n            transition={draw(mixed, 0.04)}\n          />\n        </svg>\n      </span>\n      {name && <input type=\"hidden\" name={name} value={on ? value : \"\"} />}\n    </button>\n  )\n\n  if (!label && !description) return box\n\n  return (\n    <div className=\"flex items-start gap-3\">\n      <GooduiTokens />\n      <span className={cn(\"flex items-center\", size === \"lg\" ? \"h-6\" : \"h-5\")}>{box}</span>\n      <div className=\"grid min-w-0 gap-0.5\">\n        {label && (\n          <label\n            htmlFor={id}\n            className={cn(\n              \"relative w-fit text-sm leading-5 font-medium transition-colors duration-200 select-none\",\n              // Disabled text is muted rather than faded with opacity, so it keeps 4.5:1 contrast.\n              disabled ? \"cursor-not-allowed text-muted-foreground\" : \"cursor-pointer\",\n              strikethrough && on && \"text-muted-foreground\",\n            )}\n          >\n            {label}\n            {strikethrough && (\n              <motion.span\n                aria-hidden=\"true\"\n                className=\"pointer-events-none absolute top-1/2 -inset-x-0.5 h-[1.5px] origin-left rounded-full rtl:origin-right bg-current\"\n                initial={false}\n                animate={{ scaleX: on ? 1 : 0 }}\n                transition={reduce ? { duration: 0 } : { duration: on ? 0.32 : 0.18, delay: on ? 0.12 : 0, ease: easing.inOut }}\n              />\n            )}\n          </label>\n        )}\n        {description && (\n          <p id={`${id}-desc`} className=\"text-xs text-muted-foreground\">\n            {description}\n          </p>\n        )}\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/checkbox-draw.tsx"
    }
  ],
  "categories": [
    "components",
    "inputs"
  ],
  "type": "registry:component"
}