{
  "name": "text-hover-effect",
  "type": "registry:ui",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "components/ui/text-hover-effect.tsx",
      "content": "\"use client\";\nimport React, { useRef, useEffect, useState } from \"react\";\nimport { motion } from \"motion/react\";\n\nexport const TextHoverEffect = ({\n  text,\n  duration,\n}: {\n  text: string;\n  duration?: number;\n  automatic?: boolean;\n}) => {\n  const svgRef = useRef<SVGSVGElement>(null);\n  const [cursor, setCursor] = useState({ x: 0, y: 0 });\n  const [hovered, setHovered] = useState(false);\n  const [maskPosition, setMaskPosition] = useState({ cx: \"50%\", cy: \"50%\" });\n\n  useEffect(() => {\n    if (svgRef.current && cursor.x !== null && cursor.y !== null) {\n      const svgRect = svgRef.current.getBoundingClientRect();\n      const cxPercentage = ((cursor.x - svgRect.left) / svgRect.width) * 100;\n      const cyPercentage = ((cursor.y - svgRect.top) / svgRect.height) * 100;\n      setMaskPosition({\n        cx: `${cxPercentage}%`,\n        cy: `${cyPercentage}%`,\n      });\n    }\n  }, [cursor]);\n\n  return (\n    <svg\n      ref={svgRef}\n      width=\"100%\"\n      height=\"100%\"\n      viewBox=\"0 0 300 100\"\n      xmlns=\"http://www.w3.org/2000/svg\"\n      onMouseEnter={() => setHovered(true)}\n      onMouseLeave={() => setHovered(false)}\n      onMouseMove={(e) => setCursor({ x: e.clientX, y: e.clientY })}\n      className=\"select-none\"\n    >\n      <defs>\n        <linearGradient\n          id=\"textGradient\"\n          gradientUnits=\"userSpaceOnUse\"\n          cx=\"50%\"\n          cy=\"50%\"\n          r=\"25%\"\n        >\n          {hovered && (\n            <>\n              <stop offset=\"0%\" stopColor=\"#eab308\" />\n              <stop offset=\"25%\" stopColor=\"#ef4444\" />\n              <stop offset=\"50%\" stopColor=\"#3b82f6\" />\n              <stop offset=\"75%\" stopColor=\"#06b6d4\" />\n              <stop offset=\"100%\" stopColor=\"#8b5cf6\" />\n            </>\n          )}\n        </linearGradient>\n\n        <motion.radialGradient\n          id=\"revealMask\"\n          gradientUnits=\"userSpaceOnUse\"\n          r=\"20%\"\n          initial={{ cx: \"50%\", cy: \"50%\" }}\n          animate={maskPosition}\n          transition={{ duration: duration ?? 0, ease: \"easeOut\" }}\n\n          // example for a smoother animation below\n\n          //   transition={{\n          //     type: \"spring\",\n          //     stiffness: 300,\n          //     damping: 50,\n          //   }}\n        >\n          <stop offset=\"0%\" stopColor=\"white\" />\n          <stop offset=\"100%\" stopColor=\"black\" />\n        </motion.radialGradient>\n        <mask id=\"textMask\">\n          <rect\n            x=\"0\"\n            y=\"0\"\n            width=\"100%\"\n            height=\"100%\"\n            fill=\"url(#revealMask)\"\n          />\n        </mask>\n      </defs>\n      <text\n        x=\"50%\"\n        y=\"50%\"\n        textAnchor=\"middle\"\n        dominantBaseline=\"middle\"\n        strokeWidth=\"0.3\"\n        className=\"fill-transparent stroke-neutral-200 font-[helvetica] text-7xl font-bold dark:stroke-neutral-800\"\n        style={{ opacity: hovered ? 0.7 : 0 }}\n      >\n        {text}\n      </text>\n      <motion.text\n        x=\"50%\"\n        y=\"50%\"\n        textAnchor=\"middle\"\n        dominantBaseline=\"middle\"\n        strokeWidth=\"0.3\"\n        className=\"fill-transparent stroke-neutral-200 font-[helvetica] text-7xl font-bold dark:stroke-neutral-800\"\n        initial={{ strokeDashoffset: 1000, strokeDasharray: 1000 }}\n        animate={{\n          strokeDashoffset: 0,\n          strokeDasharray: 1000,\n        }}\n        transition={{\n          duration: 4,\n          ease: \"easeInOut\",\n        }}\n      >\n        {text}\n      </motion.text>\n      <text\n        x=\"50%\"\n        y=\"50%\"\n        textAnchor=\"middle\"\n        dominantBaseline=\"middle\"\n        stroke=\"url(#textGradient)\"\n        strokeWidth=\"0.3\"\n        mask=\"url(#textMask)\"\n        className=\"fill-transparent font-[helvetica] text-7xl font-bold\"\n      >\n        {text}\n      </text>\n    </svg>\n  );\n};\n",
      "type": "registry:ui",
      "target": "components/ui/text-hover-effect.tsx"
    }
  ],
  "author": "Manu Arora <hi@manuarora.in>",
  "title": "Text Hover Effect"
}