Aurora Text
godui/aurora-textFreeComponent
Gradient text with a rainbow aurora that drifts across the letters.
Install it
npx shadcn@latest add https://godui.design/r/aurora-text.jsonSource
1"use client";23import * as React from "react";45export type AuroraTextProps = React.HTMLAttributes<HTMLSpanElement> & {6 children: React.ReactNode;7 /** Gradient stops the aurora cycles through. Defaults to a rainbow spectrum. */8 colors?: string[];9 /** Speed multiplier — `1` ≈ 10s per cycle, higher is faster. */10 speed?: number;11};1213// Full-spectrum rainbow, looped back to the first stop for a seamless cycle.14const RAINBOW_COLORS = [15 "#ff2d55",16 "#ff9500",17 "#ffd60a",18 "#34c759",19 "#00c7be",20 "#0a84ff",21 "#5e5ce6",22 "#bf5af2",23];2425const AuroraText = React.forwardRef<HTMLSpanElement, AuroraTextProps>(26 (27 {28 children,29 className,30 colors = RAINBOW_COLORS,31 speed = 1,32 style,33 ...props34 },35 ref,36 ) => {37 const stops = [...colors, colors[0]].join(", ");3839 // The gradient runs on an infinite background-position keyframe (main-thread40 // paint). Pause it whenever the text is off screen so it costs nothing while41 // idle — resumes seamlessly on scroll-in.42 const gradientRef = React.useRef<HTMLSpanElement>(null);43 React.useEffect(() => {44 const el = gradientRef.current;45 if (!el || typeof IntersectionObserver === "undefined") return;46 const io = new IntersectionObserver(47 ([entry]) => {48 el.style.animationPlayState = entry.isIntersecting ? "" : "paused";49 },50 { rootMargin: "128px" },51 );52 io.observe(el);53 return () => io.disconnect();54 }, []);5556 return (57 <span58 ref={ref}59 data-slot="aurora-text"60 className={`relative inline-block ${className ?? ""}`}61 {...props}62 >63 <span className="sr-only">{children}</span>64 <span65 ref={gradientRef}66 aria-hidden="true"67 className="animate-aurora-text bg-[length:200%_auto] bg-clip-text text-transparent motion-reduce:animate-none"68 style={69 {70 backgroundImage: `linear-gradient(135deg, ${stops})`,71 "--aurora-text-speed": `${10 / speed}s`,72 ...style,73 } as React.CSSProperties74 }75 >76 {children}77 </span>78 </span>79 );80 },81);82AuroraText.displayName = "AuroraText";8384export { AuroraText };
What it pulls in
Other registry items
Files it writes
More from godui
All 105 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | godui | Components | Free | 1 dep | |
| Agent Flowagent-flow | godui | Components | Free | 1 dep | |
| Agent Timelineagent-timeline | godui | Components | Free | 1 dep | |
| Animated Beamanimated-beam | godui | Components | Free | 1 dep | |
| Animated Testimonialsanimated-testimonials | godui | Components | Free | 1 dep | |
| Animated Tooltipanimated-tooltip | godui | Components | Free | 1 dep | |
| App Showcaseapp-showcase | godui | Components | Free | 1 dep | |
| Avatar Groupavatar-group | godui | Components | Free | 1 dep |
