{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggle-pro",
  "title": "Toggle Pro",
  "description": "An accessible switch with a springy squish animation on the thumb, an optional label + helper text, and a focus ring.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/toggle-pro/toggle-pro.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 TogglePropProps {\n  checked?: boolean;\n  defaultChecked?: boolean;\n  onCheckedChange?: (checked: boolean) => void;\n  disabled?: boolean;\n  label?: string;\n  labelPosition?: \"left\" | \"right\";\n  helperText?: string;\n  fontFamily?: string;\n  width?: number;\n  height?: number;\n  padding?: number;\n  trackOnColor?: string;\n  trackOffColor?: string;\n  thumbColor?: string;\n  ringColor?: string;\n  ringWidth?: number;\n  duration?: number;\n  squish?: number;\n  className?: string;\n}\n\nexport interface ToggleVisualProps {\n  isOn: boolean;\n  disabled: boolean;\n  ring: boolean;\n  width: number;\n  height: number;\n  padding: number;\n  trackOnColor: string;\n  trackOffColor: string;\n  thumbColor: string;\n  ringColor: string;\n  ringWidth: number;\n  duration: number;\n  squish: number;\n}\n\nexport function ToggleVisual({ isOn, disabled, ring, width, height, padding, trackOnColor, trackOffColor, thumbColor, ringColor, ringWidth, duration, squish }: ToggleVisualProps) {\n  const thumbSize = Math.max(4, height - padding * 2);\n  const maxX = Math.max(padding, width - thumbSize - padding);\n  const thumbX = isOn ? maxX : padding;\n\n  return (\n    <motion.div\n      className=\"relative box-border shrink-0\"\n      style={{ width, height, borderRadius: height / 2, opacity: disabled ? 0.45 : 1 }}\n      initial={false}\n      animate={{\n        backgroundColor: isOn ? trackOnColor : trackOffColor,\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.97 }}\n      transition={{ duration }}\n    >\n      <motion.div\n        className=\"absolute rounded-full\"\n        style={{ top: padding, left: 0, width: thumbSize, height: thumbSize, backgroundColor: thumbColor, boxShadow: \"0 1px 2px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.15)\" }}\n        initial={false}\n        animate={{ x: thumbX, scaleX: [1, 1 + squish, 1], scaleY: [1, 1 - squish * 0.6, 1] }}\n        transition={{ duration, times: [0, 0.45, 1], ease: \"easeInOut\" }}\n      />\n    </motion.div>\n  );\n}\n\nexport function TogglePro({\n  checked,\n  defaultChecked = false,\n  onCheckedChange,\n  disabled = false,\n  label,\n  labelPosition = \"right\",\n  helperText,\n  fontFamily = \"Inter, system-ui, sans-serif\",\n  width = 52,\n  height = 30,\n  padding = 3,\n  trackOnColor = \"#f59e0b\",\n  trackOffColor = \"#D1D5DB\",\n  thumbColor = \"#FFFFFF\",\n  ringColor = \"rgba(245,158,11,0.25)\",\n  ringWidth = 3,\n  duration = 0.35,\n  squish = 0.35,\n  className,\n}: TogglePropProps) {\n  const isControlled = checked !== undefined;\n  const [internalChecked, setInternalChecked] = React.useState(defaultChecked);\n  const isOn = isControlled ? checked : internalChecked;\n  const [focused, setFocused] = React.useState(false);\n  const labelSize = height * (14 / 30);\n  const helperSize = height * (13 / 30);\n\n  const handleToggle = () => {\n    if (disabled) return;\n    const next = !isOn;\n    if (!isControlled) setInternalChecked(next);\n    onCheckedChange?.(next);\n  };\n\n  return (\n    <label\n      className={cn(\n        \"inline-flex items-center select-none\",\n        disabled ? \"cursor-default\" : \"cursor-pointer\",\n        labelPosition === \"left\" && \"flex-row-reverse\",\n        className,\n      )}\n      style={{ gap: height / 3 }}\n    >\n      <span className=\"relative shrink-0\" style={{ width, height }}>\n        <input\n          type=\"checkbox\"\n          role=\"switch\"\n          aria-checked={isOn}\n          checked={isOn}\n          disabled={disabled}\n          onChange={handleToggle}\n          onFocus={() => setFocused(true)}\n          onBlur={() => setFocused(false)}\n          aria-label={label || \"toggle\"}\n          className={cn(\"absolute inset-0 m-0 h-full w-full opacity-0\", disabled ? \"cursor-default\" : \"cursor-pointer\")}\n        />\n        <ToggleVisual\n          isOn={isOn}\n          disabled={disabled}\n          ring={focused}\n          width={width}\n          height={height}\n          padding={padding}\n          trackOnColor={trackOnColor}\n          trackOffColor={trackOffColor}\n          thumbColor={thumbColor}\n          ringColor={ringColor}\n          ringWidth={ringWidth}\n          duration={duration}\n          squish={squish}\n        />\n      </span>\n\n      {label && (\n        <span className=\"flex flex-col gap-1\">\n          <span className=\"font-semibold text-foreground\" style={{ fontFamily, fontSize: labelSize }}>\n            {label}\n          </span>\n          {helperText && (\n            <span className=\"leading-snug text-foreground/60\" style={{ fontFamily, fontSize: helperSize }}>\n              {helperText}\n            </span>\n          )}\n        </span>\n      )}\n    </label>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}