{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "fluid-gradient-text", "title": "Fluid Gradient Text", "author": "ncdai ", "description": "Render text with a fluid gradient that shifts with pointer movement.", "dependencies": [ "motion" ], "files": [ { "path": "src/registry/components/fluid-gradient-text/fluid-gradient-text.tsx", "content": "\"use client\"\r\n\r\nimport { motion, useMotionValue, useSpring, useTransform } from \"motion/react\"\r\n\r\nexport type FluidGradientTextProps = {\r\n /** Text content rendered inside the SVG. */\r\n text: string\r\n /**\r\n * SVG viewBox width used to scale the gradient and text layout.\r\n * @default 1200\r\n * */\r\n svgViewBoxWidth?: number\r\n /**\r\n * SVG viewBox height used as the base text size.\r\n * @default 300\r\n * */\r\n svgViewBoxHeight?: number\r\n}\r\n\r\nexport function FluidGradientText({\r\n text,\r\n svgViewBoxWidth = 1200,\r\n svgViewBoxHeight = 300,\r\n}: FluidGradientTextProps) {\r\n const gradientX1Raw = useMotionValue(0.5)\r\n const gradientX1 = useSpring(\r\n useTransform(gradientX1Raw, [0, 1], [0, svgViewBoxWidth]),\r\n {\r\n stiffness: 150,\r\n damping: 25,\r\n }\r\n )\r\n\r\n const handleMouseMove = (event: React.MouseEvent) => {\r\n const containerRect = event.currentTarget.getBoundingClientRect()\r\n gradientX1Raw.set(\r\n (event.clientX - containerRect.left) / containerRect.width\r\n )\r\n }\r\n\r\n const handleMouseLeave = () => {\r\n gradientX1Raw.set(0.5)\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n {text}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n )\r\n}\r\n", "type": "registry:component", "target": "@components/fluid-gradient-text.tsx" } ], "docs": "https://chanhdai.com/components/fluid-gradient-text", "categories": [ "text-effects" ], "type": "registry:component" }