{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "animated-checkbox",
  "title": "Animated Checkbox",
  "description": "An accessible checkbox with an animated draw-in checkmark, focus ring, and optional label, helper text, required marker, and info tooltip.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/animated-checkbox/animated-checkbox.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface AnimatedCheckboxProps {\n  checked?: boolean;\n  defaultChecked?: boolean;\n  onCheckedChange?: (checked: boolean) => void;\n  disabled?: boolean;\n  style?: \"checkbox\" | \"toggle\";\n  label?: string;\n  optionalText?: boolean;\n  required?: boolean;\n  infoText?: string;\n  helperText?: string;\n  size?: number;\n  radius?: number;\n  borderWidth?: number;\n  borderColor?: string;\n  accentColor?: string;\n  checkColor?: string;\n  labelColor?: string;\n  helperColor?: string;\n  mutedColor?: string;\n  requiredColor?: string;\n  ringColor?: string;\n  ringWidth?: number;\n  duration?: number;\n  className?: string;\n}\n\nexport function InfoIcon({ color, size = 14 }: { color: string; size?: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n      <circle cx=\"8\" cy=\"8\" r=\"6.75\" stroke={color} strokeWidth=\"1.4\" />\n      <line x1=\"8\" y1=\"7.2\" x2=\"8\" y2=\"11.2\" stroke={color} strokeWidth=\"1.4\" strokeLinecap=\"round\" />\n      <circle cx=\"8\" cy=\"4.7\" r=\"0.9\" fill={color} />\n    </svg>\n  );\n}\n\nexport interface CheckboxVisualProps {\n  isChecked: boolean;\n  disabled: boolean;\n  ring: boolean;\n  style: \"checkbox\" | \"toggle\";\n  size: number;\n  radius: number;\n  borderWidth: number;\n  borderColor: string;\n  accentColor: string;\n  checkColor: string;\n  ringColor: string;\n  ringWidth: number;\n  duration: number;\n}\n\nexport function CheckboxVisual({ isChecked, disabled, ring, style, size, radius, borderWidth, borderColor, accentColor, checkColor, ringColor, ringWidth, duration }: CheckboxVisualProps) {\n  const isToggle = style === \"toggle\";\n  const iconSize = size * (isToggle ? 0.6 : 0.64);\n  const checkStrokeWidth = isToggle ? 2.5 : 2;\n\n  return (\n    <motion.div\n      className=\"pointer-events-none absolute inset-0 box-border flex items-center justify-center\"\n      style={{ borderRadius: radius, borderWidth, borderStyle: \"solid\", opacity: disabled ? 0.45 : 1 }}\n      initial={false}\n      animate={{\n        backgroundColor: isChecked ? accentColor : \"rgba(0,0,0,0)\",\n        borderColor: isChecked ? accentColor : borderColor,\n        boxShadow: ring ? `0 0 0 ${ringWidth}px ${ringColor}` : \"0 0 0 0px rgba(0,0,0,0)\",\n      }}\n      whileTap={disabled ? undefined : { scale: 0.92 }}\n      transition={{ duration }}\n    >\n      <svg width={iconSize} height={iconSize} viewBox=\"0 0 16 16\" className=\"absolute\">\n        <motion.path\n          d=\"M3 8.2L6.4 11.6L13 4.4\"\n          fill=\"none\"\n          stroke={checkColor}\n          strokeWidth={checkStrokeWidth}\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n          initial={false}\n          animate={{ pathLength: isChecked ? 1 : 0, opacity: isChecked ? 1 : 0 }}\n          transition={{ duration, ease: \"easeInOut\" }}\n        />\n      </svg>\n    </motion.div>\n  );\n}\n\nexport function AnimatedCheckbox({\n  checked,\n  defaultChecked = false,\n  onCheckedChange,\n  disabled = false,\n  style = \"checkbox\",\n  label = \"Accept terms and conditions\",\n  optionalText = false,\n  required = false,\n  infoText,\n  helperText,\n  size = 20,\n  radius = 6,\n  borderWidth = 1.5,\n  borderColor = \"#d1d5db\",\n  accentColor = \"#f59e0b\",\n  checkColor = \"#ffffff\",\n  labelColor = \"currentColor\",\n  helperColor = \"color-mix(in srgb, currentColor 60%, transparent)\",\n  mutedColor = \"color-mix(in srgb, currentColor 45%, transparent)\",\n  requiredColor = \"#ef4444\",\n  ringColor = \"rgba(245,158,11,0.25)\",\n  ringWidth = 3,\n  duration = 0.18,\n  className,\n}: AnimatedCheckboxProps) {\n  const [internalChecked, setInternalChecked] = React.useState(defaultChecked);\n  const [focused, setFocused] = React.useState(false);\n  const isControlled = checked !== undefined;\n  const isChecked = isControlled ? checked : internalChecked;\n  const labelSize = size * 0.7;\n  const helperSize = size * 0.65;\n\n  const handleToggle = () => {\n    if (disabled) return;\n    const next = !isChecked;\n    if (!isControlled) setInternalChecked(next);\n    onCheckedChange?.(next);\n  };\n\n  return (\n    <label\n      aria-disabled={disabled}\n      className={cn(\"inline-flex select-none\", disabled ? \"cursor-default\" : \"cursor-pointer\", label ? \"items-start\" : \"items-center\", className)}\n      style={{ fontFamily: \"Inter, sans-serif\", gap: size * 0.5 }}\n    >\n      <div className=\"relative shrink-0\" style={{ width: size, height: size }}>\n        <input\n          type=\"checkbox\"\n          role={style === \"toggle\" ? \"switch\" : undefined}\n          aria-checked={style === \"toggle\" ? isChecked : undefined}\n          checked={isChecked}\n          disabled={disabled}\n          onChange={handleToggle}\n          onFocus={() => setFocused(true)}\n          onBlur={() => setFocused(false)}\n          aria-label={label || \"checkbox\"}\n          className=\"absolute inset-0 m-0 h-full w-full opacity-0\"\n          style={{ cursor: disabled ? \"default\" : \"pointer\" }}\n        />\n        <CheckboxVisual\n          isChecked={isChecked}\n          disabled={disabled}\n          ring={focused}\n          style={style}\n          size={size}\n          radius={radius}\n          borderWidth={borderWidth}\n          borderColor={borderColor}\n          accentColor={accentColor}\n          checkColor={checkColor}\n          ringColor={ringColor}\n          ringWidth={ringWidth}\n          duration={duration}\n        />\n      </div>\n\n      {label && (\n        <div className=\"flex flex-col gap-1\" style={{ paddingTop: Math.max(0, (size - labelSize * 1.3) / 2) }}>\n          <div className=\"flex items-center gap-1.5\">\n            <span className=\"leading-[1.3] font-semibold tracking-[-0.01em]\" style={{ color: labelColor, fontSize: labelSize }}>\n              {label}\n            </span>\n            {optionalText && (\n              <span className=\"font-normal\" style={{ color: mutedColor, fontSize: labelSize }}>\n                (optional)\n              </span>\n            )}\n            {required && (\n              <span className=\"font-semibold\" style={{ color: requiredColor, fontSize: labelSize }}>\n                *\n              </span>\n            )}\n            {infoText && (\n              <span title={infoText} className=\"flex\">\n                <InfoIcon color={mutedColor} size={labelSize} />\n              </span>\n            )}\n          </div>\n          {helperText && (\n            <span className=\"leading-[1.4]\" style={{ color: helperColor, fontSize: helperSize }}>\n              {helperText}\n            </span>\n          )}\n        </div>\n      )}\n    </label>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}