{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"magnetic-button","type":"registry:ui","title":"Magnetic Button","description":"A call to action that leans toward the pointer and springs back when it leaves.","dependencies":["motion"],"registryDependencies":["https://ui.mekaigames.com/r/theme.json"],"files":[{"path":"components/ui/magnetic-button.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { motion, useMotionValue, useSpring } from \"motion/react\";\nimport type { PointerEvent, ReactNode } from \"react\";\n\ntype MagneticButtonProps = {\n  children: ReactNode;\n  /** How strongly the button follows the pointer, 0 to 1. */\n  strength?: number;\n  className?: string;\n  onClick?: () => void;\n};\n\nexport function MagneticButton({ children, strength = 0.35, className = \"\", onClick }: MagneticButtonProps) {\n  const x = useMotionValue(0);\n  const y = useMotionValue(0);\n  const sx = useSpring(x, { stiffness: 260, damping: 18, mass: 0.6 });\n  const sy = useSpring(y, { stiffness: 260, damping: 18, mass: 0.6 });\n\n  function onMove(e: PointerEvent<HTMLButtonElement>) {\n    if (e.pointerType !== \"mouse\") return;\n    const rect = e.currentTarget.getBoundingClientRect();\n    x.set((e.clientX - (rect.left + rect.width / 2)) * strength);\n    y.set((e.clientY - (rect.top + rect.height / 2)) * strength);\n  }\n\n  function reset() {\n    x.set(0);\n    y.set(0);\n  }\n\n  return (\n    <motion.button\n      type=\"button\"\n      onClick={onClick}\n      onPointerMove={onMove}\n      onPointerLeave={reset}\n      style={{ x: sx, y: sy }}\n      whileTap={{ scale: 0.95 }}\n      className={`rounded-full bg-bone px-7 py-3.5 font-display font-semibold text-black ${className}`}\n    >\n      <motion.span className=\"block\" style={{ x: sx, y: sy }}>\n        {children}\n      </motion.span>\n    </motion.button>\n  );\n}\n"}]}