# Gradient Text

> Headline text with a slowly flowing, seamlessly looping gradient.

Category: Text · Free · Updated 2026-11-10 · Live demo: https://www.motionkitui.com/components/gradient-text

## When to use it

One standout word or phrase in a headline, such as the product name or the promise, rather than whole paragraphs.

## How it works

The text uses background-clip: text, so a wide linear gradient shows through the letters. The first colour is repeated at the end, which lets Motion slide background-position from 0% to 200% on a linear loop with no visible seam.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/gradient-text.json
```

Or copy `components/motionkit/gradient-text.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `colors` | `string[]` | `["#5FAEB4", "#E4DCCF", "#A56D5B"]` | Gradient stops, left to right. |
| `duration` | `number` | `6` | Seconds per full loop. |
| `as` | `ElementType` | `"span"` | Wrapping element, e.g. "h1". |

## Accessibility

- **Keyboard: Not applicable.** Text only, nothing to focus.
- **Screen readers: Pass.** Real text, read normally. The gradient is pure CSS.
- **Reduced motion: Partial.** The gradient holds still for reduced-motion users. It loops forever otherwise, so if it sits beside other content for more than 5 seconds, WCAG 2.2.2 asks you to add a pause control.
- **Colour contrast: Partial.** The lowest default stop (Clay) measures exactly 4.5:1 on the dark surface, so it passes AA but has no margin. Re-check if you change the colours or background.

## Source

```tsx
"use client";

import type { ElementType, ReactNode } from "react";
import { motion, useReducedMotion } from "motion/react";

type GradientTextProps = {
  children: ReactNode;
  /** Gradient stops, left to right. The first color is repeated to make the loop seamless. */
  colors?: string[];
  /** Seconds per full loop. */
  duration?: number;
  /** Wrapping element, e.g. "h1". */
  as?: ElementType;
  className?: string;
};

export function GradientText({
  children,
  colors = ["#9FD8DC", "#B9C7FF", "#D6A7CE"],
  duration = 6,
  as: Tag = "span",
  className = "",
}: GradientTextProps) {
  const reduceMotion = useReducedMotion();

  return (
    <Tag className={className}>
      <motion.span
        className="bg-clip-text text-transparent [background-size:200%_auto] [box-decoration-break:clone]"
        style={{ backgroundImage: `linear-gradient(90deg, ${[...colors, colors[0]].join(", ")})` }}
        animate={reduceMotion ? undefined : { backgroundPosition: ["0% 50%", "200% 50%"] }}
        transition={{ duration, repeat: Infinity, ease: "linear" }}
      >
        {children}
      </motion.span>
    </Tag>
  );
}
```
