{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radix-checkbox",
  "title": "Radix Checkbox",
  "description": "An accessible, stylable checkbox built on Radix UI with a Motion-friendly animated indicator.",
  "dependencies": ["radix-ui", "motion"],
  "registryDependencies": ["utils", "@soralabs/hooks-use-controlled-state"],
  "files": [
    {
      "path": "registry/ui/radix/checkbox/index.tsx",
      "content": "\"use client\";\n\nimport { useControlledState } from \"@/hooks/use-controlled-state\";\nimport { cn } from \"@/lib/utils\";\nimport {\n  motion,\n  useMotionValue,\n  useReducedMotion,\n  useTransform,\n} from \"motion/react\";\nimport { Checkbox as CheckboxPrimitive } from \"radix-ui\";\nimport { useId } from \"react\";\nimport type { ComponentProps, ReactNode } from \"react\";\n\ninterface CheckboxCheckIconProps extends Omit<\n  ComponentProps<\"svg\">,\n  \"children\"\n> {\n  /** Whether the checkbox checkmark is active. */\n  checked: boolean;\n  /** Whether reduced motion is enabled. */\n  prefersReducedMotion?: boolean | null;\n}\n\n/**\n * Checkmark SVG icon featuring animated path length draw with dynamic round cap transform.\n */\nfunction CheckboxCheckIcon({\n  checked,\n  className,\n  prefersReducedMotion,\n  ...props\n}: CheckboxCheckIconProps) {\n  const pathLength = useMotionValue(checked ? 1 : 0);\n  const strokeLinecap = useTransform(() =>\n    pathLength.get() === 0 ? \"none\" : \"round\"\n  );\n\n  return (\n    <svg\n      aria-hidden=\"true\"\n      className={cn(\"size-3.5 stroke-current\", className)}\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"3\"\n      viewBox=\"0 0 24 24\"\n      {...props}\n    >\n      <motion.path\n        animate={{ pathLength: checked ? 1 : 0 }}\n        d=\"M4 12L10 18L20 6\"\n        style={\n          {\n            pathLength,\n            strokeLinecap,\n          } as ComponentProps<typeof motion.path>[\"style\"]\n        }\n        transition={\n          prefersReducedMotion\n            ? { duration: 0 }\n            : {\n                type: \"spring\",\n                bounce: 0,\n                duration: checked ? 0.3 : 0.1,\n              }\n        }\n      />\n    </svg>\n  );\n}\n\ntype CheckboxRootProps = ComponentProps<typeof CheckboxPrimitive.Root>;\n\n/**\n * Primitive root button for the checkbox component, wrapping Radix UI's Checkbox.Root with Motion interaction states.\n * Supports full Tailwind CSS class overriding via `cn(...)`.\n */\nfunction CheckboxRoot({ className, ...props }: CheckboxRootProps) {\n  const prefersReducedMotion = useReducedMotion();\n\n  return (\n    <CheckboxPrimitive.Root\n      asChild\n      className={cn(\n        \"peer border-input focus-visible:border-ring focus-visible:ring-ring/50 group-has-[:focus-visible]/field-label:not-data-[state=checked]:border-input aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground aria-invalid:data-[state=checked]:border-primary group-has-[:focus-visible]/field-label:data-[state=checked]:border-primary dark:bg-input/30 dark:data-[state=checked]:bg-primary dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[4px] border transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3\",\n        className\n      )}\n      data-slot=\"checkbox\"\n      {...props}\n    >\n      <motion.button\n        data-primary-action\n        type=\"button\"\n        whileHover={prefersReducedMotion ? undefined : { scale: 1.05 }}\n        whileTap={prefersReducedMotion ? undefined : { scale: 0.95 }}\n      />\n    </CheckboxPrimitive.Root>\n  );\n}\n\ntype CheckboxIndicatorProps = ComponentProps<\n  typeof CheckboxPrimitive.Indicator\n> & {\n  /** Whether the checkbox is currently checked */\n  checked?: boolean;\n};\n\n/**\n * Animated checkmark indicator for the checkbox using Motion path length animation.\n */\nfunction CheckboxIndicator({\n  className,\n  checked = false,\n  ...props\n}: CheckboxIndicatorProps) {\n  const prefersReducedMotion = useReducedMotion();\n\n  return (\n    <CheckboxPrimitive.Indicator\n      className={cn(\n        \"grid place-content-center text-current transition-none [&>svg]:size-3.5\",\n        className\n      )}\n      data-slot=\"checkbox-indicator\"\n      forceMount\n      {...props}\n    >\n      <CheckboxCheckIcon\n        checked={checked}\n        className={className}\n        prefersReducedMotion={prefersReducedMotion}\n      />\n    </CheckboxPrimitive.Indicator>\n  );\n}\n\ninterface CheckboxProps extends CheckboxRootProps {\n  /**\n   * Optional class name for the animated checkmark SVG indicator.\n   */\n  indicatorClassName?: string;\n  /**\n   * Optional label rendered beside the checkbox (wraps both in a `<label>`).\n   */\n  label?: ReactNode;\n  /**\n   * Optional class name for the outer label wrapper.\n   */\n  labelClassName?: string;\n}\n\n/**\n * An accessible, stylable animated Checkbox component built with Radix UI and Motion for React.\n * Supports full Tailwind CSS class overrides just like shadcn/ui.\n */\nfunction Checkbox({\n  checked: controlledChecked,\n  defaultChecked = false,\n  onCheckedChange,\n  label,\n  labelClassName,\n  indicatorClassName,\n  className,\n  id,\n  disabled,\n  ...props\n}: CheckboxProps) {\n  const generatedId = useId();\n  const inputId = id ?? generatedId;\n\n  const [isChecked, setIsChecked] = useControlledState({\n    defaultValue: defaultChecked,\n    onChange: onCheckedChange,\n    value: controlledChecked,\n  });\n\n  const prefersReducedMotion = useReducedMotion();\n  const isCheckedBool = Boolean(isChecked && isChecked !== \"indeterminate\");\n\n  const control = (\n    <CheckboxPrimitive.Root\n      asChild\n      checked={isChecked}\n      className={cn(\n        \"peer border-input focus-visible:border-ring focus-visible:ring-ring/50 group-has-[:focus-visible]/field-label:not-data-[state=checked]:border-input aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground aria-invalid:data-[state=checked]:border-primary group-has-[:focus-visible]/field-label:data-[state=checked]:border-primary dark:bg-input/30 dark:data-[state=checked]:bg-primary dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[4px] border transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3\",\n        className\n      )}\n      data-slot=\"checkbox\"\n      disabled={disabled}\n      id={inputId}\n      onCheckedChange={setIsChecked}\n      {...props}\n    >\n      <motion.button\n        data-primary-action\n        type=\"button\"\n        whileHover={prefersReducedMotion ? undefined : { scale: 1.05 }}\n        whileTap={prefersReducedMotion ? undefined : { scale: 0.95 }}\n      >\n        <CheckboxPrimitive.Indicator forceMount>\n          <CheckboxCheckIcon\n            checked={isCheckedBool}\n            className={indicatorClassName}\n            prefersReducedMotion={prefersReducedMotion}\n          />\n        </CheckboxPrimitive.Indicator>\n      </motion.button>\n    </CheckboxPrimitive.Root>\n  );\n\n  if (label === null || label === undefined) {\n    return control;\n  }\n\n  return (\n    <div className=\"inline-flex items-center gap-2.5\">\n      {control}\n      <label\n        className={cn(\n          \"cursor-pointer text-sm leading-none font-medium select-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n          disabled && \"cursor-not-allowed opacity-50\",\n          labelClassName\n        )}\n        htmlFor={inputId}\n      >\n        {label}\n      </label>\n    </div>\n  );\n}\n\nexport type {\n  CheckboxCheckIconProps,\n  CheckboxIndicatorProps,\n  CheckboxProps,\n  CheckboxRootProps,\n};\nexport {\n  Checkbox,\n  Checkbox as RadixCheckbox,\n  Checkbox as default,\n  CheckboxCheckIcon,\n  CheckboxIndicator,\n  CheckboxRoot,\n};\n",
      "type": "registry:ui",
      "target": "components/sora-ui/radix/checkbox.tsx"
    }
  ],
  "meta": {
    "agentMetadata": {
      "intent": "Toggle an independent boolean setting with Radix state semantics.",
      "role": "input",
      "a11yConstraints": [
        "Preserve the checkbox role, label association, and keyboard toggling."
      ],
      "motionEngine": "Motion checkmark and scale feedback synchronized with checked state.",
      "compositionRules": [
        "Pair with a visible label and explicit form submission semantics."
      ],
      "compositionRecipes": ["Compose with radix/button in a preference form."]
    },
    "demoProps": {
      "Checkbox": {
        "label": {
          "value": "Accept terms and conditions"
        },
        "disabled": {
          "value": false
        }
      }
    }
  },
  "type": "registry:ui"
}
