{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "magnetic-button",
  "type": "registry:component",
  "description": "A Button component with magnetic effect animation on hover.",
  "dependencies": [],
  "registryDependencies": [
    "button"
  ],
  "files": [
    {
      "path": "src/app/components/animatedComponents/buttons/magnetic/MagneticButton.tsx",
      "content": "'use client'\r\n\r\nimport * as React from 'react'\r\n\r\nimport { motion, type HTMLMotionProps, type Transition } from 'motion/react'\r\nimport type { VariantProps } from 'class-variance-authority'\r\n\r\nimport { cn } from '@/lib/utils'\r\nimport { buttonVariants } from '@/components/ui/button'\r\n\r\ninterface Position {\r\n  x: number\r\n  y: number\r\n}\r\n\r\ninterface MagneticButtonProps extends HTMLMotionProps<'button'>, VariantProps<typeof buttonVariants> {\r\n  scale?: number\r\n  transition?: Transition\r\n}\r\n\r\nfunction MagneticButton({ className, size, variant, ...props }: MagneticButtonProps) {\r\n  const ref = React.useRef<HTMLButtonElement>(null)\r\n  const [position, setPosition] = React.useState<Position>({ x: 0, y: 0 })\r\n\r\n  const handleMouse = (e: React.MouseEvent<HTMLButtonElement>) => {\r\n    if (ref.current) {\r\n      const { clientX, clientY } = e\r\n      const { height, width, left, top } = ref.current.getBoundingClientRect()\r\n      const middleX = clientX - (left + width / 2)\r\n      const middleY = clientY - (top + height / 2)\r\n\r\n      setPosition({ x: middleX, y: middleY })\r\n    }\r\n  }\r\n\r\n  const reset = () => {\r\n    setPosition({ x: 0, y: 0 })\r\n  }\r\n\r\n  const { x, y } = position\r\n\r\n  return (\r\n    <motion.button\r\n      ref={ref}\r\n      onMouseMove={handleMouse}\r\n      onMouseLeave={reset}\r\n      animate={{ x, y }}\r\n      transition={{ type: 'spring', stiffness: 170, damping: 18, mass: 0.1 }}\r\n      whileTap={{\r\n        scale: 0.75\r\n      }}\r\n      className={cn(buttonVariants({ variant, size }), 'relative transition-none', className)}\r\n      {...props}\r\n    >\r\n      Magnetic Button\r\n    </motion.button>\r\n  )\r\n}\r\n\r\nexport { MagneticButton, type MagneticButtonProps }\r\n",
      "type": "registry:component",
      "target": "components/animated/buttons/magnetic/MagneticButton.tsx"
    }
  ]
}