{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "magnetic",
  "title": "Magnetic",
  "author": "VenusUI",
  "description": "Wraps any element so it is pulled toward the mouse pointer and springs back.",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "registry/default/ui/magnetic.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useMotionValue, useReducedMotion, useSpring } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface MagneticProps {\n  children: React.ReactNode\n  /** How far the content follows the pointer, from 0 (not at all) to 1 (fully). */\n  strength?: number\n  /** Extra space around the content, in pixels, where the pull starts. */\n  range?: number\n  className?: string\n}\n\nconst SPRING = { stiffness: 220, damping: 16, mass: 0.3 }\n\n/**\n * Pulls its content toward the mouse pointer, then springs back when the\n * pointer leaves. Wrap a button, icon or link. Mouse only; no movement when\n * the user prefers reduced motion.\n */\nfunction Magnetic({ children, strength = 0.35, range = 24, className }: MagneticProps) {\n  const reduceMotion = useReducedMotion()\n  const x = useSpring(useMotionValue(0), SPRING)\n  const y = useSpring(useMotionValue(0), SPRING)\n\n  function onPointerMove(event: React.PointerEvent<HTMLDivElement>) {\n    if (reduceMotion || event.pointerType !== \"mouse\") return\n    const rect = event.currentTarget.getBoundingClientRect()\n    x.set((event.clientX - (rect.left + rect.width / 2)) * strength)\n    y.set((event.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    <div\n      data-slot=\"magnetic\"\n      className={cn(\"inline-flex\", className)}\n      style={{ padding: range, margin: -range }}\n      onPointerMove={onPointerMove}\n      onPointerLeave={reset}\n    >\n      <motion.div className=\"inline-flex\" style={{ x, y }}>\n        {children}\n      </motion.div>\n    </div>\n  )\n}\n\nexport { Magnetic, type MagneticProps }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "effects"
  ],
  "type": "registry:ui"
}