# Animated gradient text

> A band of color drifts slowly across the headline, over and over, while the rest keeps your text color.

- Category: [Text & scroll](https://library.aimran.es/components/text-scroll)
- Built with: React + Motion
- Live editor: https://library.aimran.es/blocks/animated-gradient-text
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A moving gradient gives a big headline some life without adding another element to the page. It suits the slogan of a creative studio, the name of an app on its landing page or the title of a conference. Many people search for animated gradient text in CSS; this version is ready for React and stays readable the whole time.

Pick an accent that contrasts with your text color, or the sweep is barely visible. Five seconds per pass feels relaxed, faster gets restless. Save it for large type; on small text it just looks like a rendering glitch.

## Code

### React (Motion)

```tsx
import { motion } from "framer-motion";

interface GradientTextProps {
  text?: string;
  color?: string;
  /** Segundos por pasada del degradado. */
  speed?: number;
}

export default function GradientText({
  text = "Designed to flow",
  color = "#0071e3",
  speed = 5,
}: GradientTextProps) {
  return (
    // --gradient-fg es el color del texto normal, para que el degradado respete el modo oscuro
    <motion.h2
      className="bg-clip-text text-4xl font-semibold text-transparent [--gradient-fg:#1d1d1f] dark:[--gradient-fg:#f5f5f7]"
      style={{
        backgroundImage: `linear-gradient(90deg,var(--gradient-fg),${color},var(--gradient-fg))`,
        backgroundSize: "200% 100%",
      }}
      animate={{ backgroundPosition: ["0% 0", "200% 0"] }}
      transition={{ duration: speed, repeat: Infinity, ease: "linear" }}
    >
      {text}
    </motion.h2>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Animated gradient text” block (Text & scroll) from AIMRAN Library to my project.

## What it is
A band of color drifts slowly across the headline, over and over, while the rest keeps your text color.

## Chosen settings
- Text: "Designed to flow"
- Color: #0071e3
- Speed: 5s (from 2 to 8s)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with React + TypeScript, with framer-motion for the animation and lucide-react for the icons. If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
import { motion } from "framer-motion";

interface GradientTextProps {
  text?: string;
  color?: string;
  /** Segundos por pasada del degradado. */
  speed?: number;
}

export default function GradientText({
  text = "Designed to flow",
  color = "#0071e3",
  speed = 5,
}: GradientTextProps) {
  return (
    // --gradient-fg es el color del texto normal, para que el degradado respete el modo oscuro
    <motion.h2
      className="bg-clip-text text-4xl font-semibold text-transparent [--gradient-fg:#1d1d1f] dark:[--gradient-fg:#f5f5f7]"
      style={{
        backgroundImage: `linear-gradient(90deg,var(--gradient-fg),${color},var(--gradient-fg))`,
        backgroundSize: "200% 100%",
      }}
      animate={{ backgroundPosition: ["0% 0", "200% 0"] }}
      transition={{ duration: speed, repeat: Infinity, ease: "linear" }}
    >
      {text}
    </motion.h2>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
