Text Effects
GradientPulse
A gradient slides slowly through the letters while the text gently brightens and dims.
Download
- React
- Tailwind CSS v4
- motion
components/ui/gradient-pulse.tsx
"use client";
import type { ReactNode } from "react";
import { motion, useReducedMotion } from "motion/react";
type GradientPulseProps = {
children: ReactNode;
className?: string;
/** Gradient colours, left to right. */
colors?: string[];
/** Seconds for one full sweep there and back. */
duration?: number;
};
/* GradientPulse: a gradient slides slowly through the letters while the text gently brightens and dims. */
export function GradientPulse({
children,
className = "",
colors = ["#a78bfa", "#f472b6", "#fbbf24", "#34f5c5"],
duration = 6,
}: GradientPulseProps) {
const reduce = useReducedMotion();
return (
<motion.span
className={`bg-clip-text text-transparent ${className}`}
style={{ backgroundImage: `linear-gradient(90deg, ${colors.join(", ")})`, backgroundSize: "300% 100%" }}
animate={
reduce
? undefined
: { backgroundPosition: ["0% 50%", "100% 50%", "0% 50%"], filter: ["brightness(1)", "brightness(1.3)", "brightness(1)"] }
}
transition={{ duration, repeat: Infinity, ease: "easeInOut" }}
>
{children}
</motion.span>
);
}
1. Install the dependency.
npm i motion2. Paste the Code tab into
components/ui/gradient-pulse.tsx. The styles are Tailwind CSS v4 classes.3. Use it. This is the preview above:
app/gradient-pulse-demo.tsx
import { GradientPulse } from "@/components/ui/gradient-pulse"; export default function GradientPulseExample() { return ( <div className="grid h-full place-items-center bg-[#0d0c14] p-6"> <GradientPulse className="text-center text-[clamp(32px,6vw,72px)] font-black tracking-tight">Make it glow</GradientPulse> </div> ); }
Props
| Name | Type | Default | What it does |
|---|---|---|---|
| children | ReactNode | — | Text to fill. |
| colors | string[] | ["#a78bfa", "#f472b6", "#fbbf24", "#34f5c5"] | Gradient colours, left to right. |
| duration | number | 6 | Seconds for one sweep there and back. |
| className | string | "" | Type styles for the text. |