{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cursor-follower",
  "type": "registry:ui",
  "title": "Cursor Follower",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Dual-spring custom pointer stage with a high-stiffness inner core and morphing outer ring that expands into contextual HUD pills.",
  "dependencies": [
    "framer-motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/cursor-follower.tsx",
      "content": "\"use client\";\n\nimport React, { useRef, useState } from \"react\";\nimport {\n  motion,\n  AnimatePresence,\n  useMotionValue,\n  useSpring,\n  useReducedMotion,\n} from \"framer-motion\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CursorFollowerProps {\n  children: React.ReactNode;\n  className?: string;\n  /** Custom accent color override for the cursor ring and dot */\n  accentColor?: string;\n  /** Spring stiffness for the outer trailing ring. Default: 260 */\n  ringStiffness?: number;\n  /** Spring damping for the outer trailing ring. Default: 22 */\n  ringDamping?: number;\n  /** Size of the outer ring in pixels when idle. Default: 34 */\n  ringSize?: number;\n  /** Show coordinate HUD readout in corner of stage. Default: true */\n  showCoordinates?: boolean;\n}\n\nexport function CursorFollower({\n  children,\n  className,\n  accentColor,\n  ringStiffness = 260,\n  ringDamping = 22,\n  ringSize = 34,\n  showCoordinates = true,\n}: CursorFollowerProps) {\n  const containerRef = useRef<HTMLDivElement>(null);\n  const shouldReduceMotion = useReducedMotion();\n\n  const [isInside, setIsInside] = useState(false);\n  const [isPressed, setIsPressed] = useState(false);\n  const [activeLabel, setActiveLabel] = useState<string | null>(null);\n  const [coords, setCoords] = useState({ x: 0, y: 0 });\n\n  const rawX = useMotionValue(0);\n  const rawY = useMotionValue(0);\n\n  const dotX = useSpring(rawX, { stiffness: 750, damping: 35, mass: 0.1 });\n  const dotY = useSpring(rawY, { stiffness: 750, damping: 35, mass: 0.1 });\n\n  const ringX = useSpring(rawX, {\n    stiffness: ringStiffness,\n    damping: ringDamping,\n    mass: 0.35,\n  });\n  const ringY = useSpring(rawY, {\n    stiffness: ringStiffness,\n    damping: ringDamping,\n    mass: 0.35,\n  });\n\n  const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n    if (!containerRef.current) return;\n    const rect = containerRef.current.getBoundingClientRect();\n    const x = Math.round(e.clientX - rect.left);\n    const y = Math.round(e.clientY - rect.top);\n\n    rawX.set(x);\n    rawY.set(y);\n    setCoords({ x, y });\n\n    const target = e.target as HTMLElement | null;\n    const labeledEl = target?.closest(\n      \"[data-cursor-label]\"\n    ) as HTMLElement | null;\n    if (labeledEl) {\n      setActiveLabel(labeledEl.getAttribute(\"data-cursor-label\"));\n    } else {\n      setActiveLabel(null);\n    }\n  };\n\n  return (\n    <div\n      ref={containerRef}\n      onMouseEnter={() => setIsInside(true)}\n      onMouseLeave={() => {\n        setIsInside(false);\n        setIsPressed(false);\n        setActiveLabel(null);\n      }}\n      onMouseDown={() => setIsPressed(true)}\n      onMouseUp={() => setIsPressed(false)}\n      onMouseMove={handleMouseMove}\n      className={cn(\n        \"relative overflow-hidden rounded-2xl border border-neutral-200 bg-neutral-50 select-none dark:border-[#222222] dark:bg-black\",\n        isInside && !shouldReduceMotion && \"cursor-none\",\n        className\n      )}\n    >\n      {showCoordinates && (\n        <div className=\"pointer-events-none absolute right-3.5 top-3.5 z-20 flex items-center gap-2 rounded-full border border-neutral-200 bg-white px-2.5 py-1 font-mono text-[10px] text-neutral-500 dark:border-[#262626] dark:bg-[#0A0A0A] dark:text-neutral-400\">\n          <span\n            className={cn(\n              \"h-1.5 w-1.5 rounded-full transition-colors\",\n              isInside\n                ? \"bg-black dark:bg-white\"\n                : \"bg-neutral-300 dark:bg-neutral-700\"\n            )}\n            style={\n              isInside && accentColor\n                ? { backgroundColor: accentColor }\n                : undefined\n            }\n          />\n          <span>\n            X:{coords.x.toString().padStart(3, \"0\")} Y:\n            {coords.y.toString().padStart(3, \"0\")}\n          </span>\n        </div>\n      )}\n\n      <div className=\"relative z-10\">{children}</div>\n\n      {!shouldReduceMotion && (\n        <AnimatePresence>\n          {isInside && (\n            <>\n              <motion.div\n                aria-hidden=\"true\"\n                initial={{ opacity: 0, scale: 0 }}\n                animate={{\n                  opacity: activeLabel ? 0 : 1,\n                  scale: isPressed ? 0.7 : 1,\n                }}\n                exit={{ opacity: 0, scale: 0 }}\n                style={{\n                  x: dotX,\n                  y: dotY,\n                  translateX: \"-50%\",\n                  translateY: \"-50%\",\n                  ...(accentColor ? { backgroundColor: accentColor } : {}),\n                }}\n                className=\"pointer-events-none absolute left-0 top-0 z-30 h-2 w-2 rounded-full bg-black dark:bg-white\"\n              />\n\n              <motion.div\n                aria-hidden=\"true\"\n                initial={{ opacity: 0, scale: 0.4 }}\n                animate={{\n                  opacity: 1,\n                  scale: isPressed ? 0.88 : 1,\n                  width: activeLabel ? \"auto\" : ringSize,\n                  height: activeLabel ? 30 : ringSize,\n                }}\n                exit={{ opacity: 0, scale: 0.4 }}\n                transition={{\n                  width: { type: \"spring\", stiffness: 380, damping: 28 },\n                  height: { type: \"spring\", stiffness: 380, damping: 28 },\n                }}\n                style={{\n                  x: ringX,\n                  y: ringY,\n                  translateX: \"-50%\",\n                  translateY: \"-50%\",\n                  ...(accentColor ? { borderColor: accentColor } : {}),\n                }}\n                className={cn(\n                  \"pointer-events-none absolute left-0 top-0 z-30 flex items-center justify-center rounded-full border border-black transition-colors duration-150 dark:border-white\",\n                  activeLabel\n                    ? \"bg-black px-3 text-white shadow-lg dark:bg-white dark:text-black\"\n                    : \"bg-black/5 backdrop-blur-sm dark:bg-white/10\"\n                )}\n              >\n                {activeLabel && (\n                  <motion.span\n                    initial={{ opacity: 0, scale: 0.85 }}\n                    animate={{ opacity: 1, scale: 1 }}\n                    exit={{ opacity: 0, scale: 0.85 }}\n                    className=\"whitespace-nowrap font-mono text-[10px] font-semibold tracking-wider text-white dark:text-black\"\n                  >\n                    {activeLabel}\n                  </motion.span>\n                )}\n              </motion.div>\n            </>\n          )}\n        </AnimatePresence>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/cursor-follower.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
