Moving Gradient Text
wise-ui/moving-gradient-textFreeComponent
Text with a continuously flowing gradient animation.
Live preview
live · rendered by the registry
Rendered by wise-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://wise-ui.com/r/moving-gradient-text.jsonSource
1"use client"23import * as React from "react"4import { motion, useMotionValue, useTransform, animate } from "motion/react"5import { cn } from "@/registry/wise-ui/lib/utils"67interface MovingGradientTextProps {8 gradientFrom?: string9 gradientTo?: string10 speed?: number11 className?: string12 style?: React.CSSProperties13 children: React.ReactNode14}1516const MovingGradientText = React.forwardRef<17 HTMLSpanElement,18 MovingGradientTextProps19>(20 (21 {22 gradientFrom = "#00a896",23 gradientTo = "#c084fc",24 speed = 1,25 children,26 className,27 style,28 },29 ref30 ) => {31 const rotation = useMotionValue(0)32 const controlRef = React.useRef<ReturnType<typeof animate> | null>(null)3334 React.useEffect(() => {35 controlRef.current = animate(36 rotation,37 rotation.get() + 360 * 10000,38 { duration: (3 / speed) * 10000, ease: "linear" }39 )40 return () => {41 controlRef.current?.stop()42 }43 }, [speed, rotation])4445 const backgroundPosition = useTransform(46 rotation,47 (v) => `${-(v * 100) / 360}% 0%`48 )4950 return (51 <motion.span52 ref={ref}53 className={cn("inline-block", className)}54 style={{55 backgroundImage: `linear-gradient(90deg, ${gradientFrom}, ${gradientTo}, ${gradientFrom})`,56 backgroundSize: "200% 100%",57 backgroundRepeat: "repeat",58 backgroundPosition,59 WebkitBackgroundClip: "text",60 WebkitTextFillColor: "transparent",61 backgroundClip: "text",62 ...style,63 }}64 >65 {children}66 </motion.span>67 )68 }69)70MovingGradientText.displayName = "MovingGradientText"7172export { MovingGradientText }73export type { MovingGradientTextProps }
What it pulls in
npm packages
Files it writes
More from wise-ui
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Tabsanimated-tabs | wise-ui | Components | Free | 3 deps | |
| Border Beamborder-beam | wise-ui | Components | Free | 3 deps | |
| Data Tabledata-table | wise-ui | Components | Free | 3 deps | |
| Dockdock | wise-ui | Components | Free | 3 deps | |
| Dot Matrixdot-matrix | wise-ui | Components | Free | 2 deps | |
| Editable Texteditable-text | wise-ui | Components | Free | 4 deps | |
| Gradient Sidebargradient-sidebar | wise-ui | Components | Free | 3 deps | |
| Kanban Boardkanban-board | wise-ui | Components | Free | 6 deps |
