{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"pop-check","type":"registry:ui","title":"Pop Check","description":"Checkbox that squashes on press, pops and wobbles when checked, floods with color from the center and springs its tick in with a spark burst.","dependencies":["motion"],"registryDependencies":[],"files":[{"path":"registry/ui/pop-check.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useId, useState, type ReactNode } from \"react\";\nimport { MotionConfig, motion } from \"motion/react\";\n\nexport interface PopCheckProps {\n  /** Controlled checked state. */\n  checked?: boolean;\n  /** Initial state when uncontrolled. */\n  defaultChecked?: boolean;\n  onChange?: (checked: boolean) => void;\n  label?: ReactNode;\n  /** Fill color when checked. */\n  color?: string;\n  /** Box size in px. */\n  size?: number;\n  disabled?: boolean;\n  /** Form field name. */\n  name?: string;\n  className?: string;\n}\n\nconst SPARKS = 6;\n\nexport function PopCheck({\n  checked,\n  defaultChecked = false,\n  onChange,\n  label = \"Ship it\",\n  color = \"#22c55e\",\n  size = 28,\n  disabled = false,\n  name,\n  className,\n}: PopCheckProps) {\n  const id = useId();\n  const [inner, setInner] = useState(defaultChecked);\n  const [pops, setPops] = useState(0);\n  const on = checked ?? inner;\n\n  const toggle = () => {\n    const next = !on;\n    if (checked === undefined) setInner(next);\n    if (next) setPops((p) => p + 1);\n    onChange?.(next);\n  };\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <label\n        htmlFor={id}\n        className={`group inline-flex select-none items-center gap-3 text-sm font-medium text-foreground ${disabled ? \"cursor-not-allowed opacity-50\" : \"cursor-pointer\"} ${className ?? \"\"}`}\n      >\n        <span\n          className={`relative grid shrink-0 place-items-center transition-[scale] duration-150 motion-reduce:transition-none ${disabled ? \"\" : \"group-active:scale-[0.82]\"}`}\n          style={{ width: size, height: size }}\n        >\n          <input\n            id={id}\n            type=\"checkbox\"\n            name={name}\n            checked={on}\n            disabled={disabled}\n            onChange={toggle}\n            className=\"peer absolute inset-0 m-0 cursor-[inherit] appearance-none rounded-[28%] outline-none\"\n          />\n          {/* Sparks fly off the corners on each check. */}\n          {on && pops > 0 && (\n            <span key={pops} aria-hidden className=\"pointer-events-none absolute inset-0\">\n              {Array.from({ length: SPARKS }, (_, i) => {\n                const a = (i / SPARKS) * 360 + 30;\n                return (\n                  <span key={i} className=\"absolute left-1/2 top-1/2 h-0 w-0\" style={{ rotate: `${a}deg` }}>\n                    <motion.span\n                      className=\"absolute -top-px left-0 h-0.5 rounded-full\"\n                      style={{ background: color, width: size * 0.3 }}\n                      initial={{ x: size * 0.45, scaleX: 0, opacity: 1 }}\n                      animate={{ x: size * 0.95, scaleX: [0, 1, 0], opacity: [1, 1, 0] }}\n                      transition={{ duration: 0.45, ease: \"easeOut\", delay: 0.12 }}\n                    />\n                  </span>\n                );\n              })}\n            </span>\n          )}\n          <motion.span\n            aria-hidden\n            className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[28%] border-2 bg-background transition-[border-color,box-shadow] duration-200 peer-focus-visible:ring-[3px] peer-focus-visible:ring-ring/60\"\n            style={{ borderColor: on ? color : \"color-mix(in oklab, var(--muted-foreground) 55%, transparent)\" }}\n            initial={false}\n            animate={\n              on\n                ? { scale: [0.78, 1.18, 0.94, 1.03, 1], rotate: [0, -8, 4, 0] }\n                : { scale: [0.86, 1.06, 1], rotate: 0 }\n            }\n            transition={{ duration: on ? 0.55 : 0.3, ease: \"easeOut\" }}\n          >\n            <motion.span\n              className=\"absolute inset-0 rounded-full\"\n              style={{ background: color }}\n              initial={false}\n              animate={{ scale: on ? 1.5 : 0 }}\n              transition={on ? { type: \"spring\", stiffness: 380, damping: 22 } : { duration: 0.18 }}\n            />\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" className=\"absolute inset-0 size-full p-[18%]\">\n              <motion.path\n                d=\"M4.5 12.5l5 5L19.5 7\"\n                stroke=\"white\"\n                strokeWidth=\"3.4\"\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n                initial={false}\n                animate={{ pathLength: on ? 1 : 0, opacity: on ? 1 : 0 }}\n                transition={\n                  on\n                    ? { pathLength: { type: \"spring\", stiffness: 300, damping: 14, delay: 0.08 }, opacity: { duration: 0.05, delay: 0.08 } }\n                    : { duration: 0.15 }\n                }\n              />\n            </svg>\n          </motion.span>\n        </span>\n        {label}\n      </label>\n    </MotionConfig>\n  );\n}\n"}]}