Animated Gradient Text
- Source
- Magic UI ↗
- Author
- Magic UI
- Licence
- MIT
Loading…
A pill badge whose text and border carry a slowly sliding gradient.
Code
"use client";
import { ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { AnimatedGradientText } from "@/lab/magicui/ui/animated-gradient-text";
export default function AnimatedGradientTextDemo() {
return (
<div className="relative flex h-full w-full items-center justify-center">
<div className="group relative mx-auto flex items-center justify-center rounded-full px-4 py-1.5 shadow-[inset_0_-8px_10px_#8fdfff1f] transition-shadow duration-500 ease-out hover:shadow-[inset_0_-5px_10px_#8fdfff3f]">
<span
className={cn(
"animate-magic-gradient absolute inset-0 block h-full w-full rounded-[inherit] bg-gradient-to-r from-[#ffaa40]/50 via-[#9c40ff]/50 to-[#ffaa40]/50 bg-[length:300%_100%] p-[1px]",
)}
style={{
WebkitMask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
WebkitMaskComposite: "destination-out",
mask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
maskComposite: "subtract",
WebkitClipPath: "padding-box",
}}
/>
🎉 <hr className="mx-2 h-4 w-px shrink-0 bg-neutral-500" />
<AnimatedGradientText className="text-sm font-medium">Introducing Magic UI</AnimatedGradientText>
<ChevronRight className="ml-1 size-4 stroke-neutral-500 transition-transform duration-300 ease-in-out group-hover:translate-x-0.5" />
</div>
</div>
);
}
Prompt
Build "Animated Gradient Text", a text animation. What it does: A pill badge whose text and border carry a slowly sliding gradient. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using lucide-react. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://magicui.design/docs/components/animated-gradient-text (Magic UI, MIT).