Skip to content
English

How it works

The gradient is three times as wide as the text, clipped to the glyphs, and its position drifts back and forth with an ease-in-out, so colour flows through the letters and slows at each end instead of sliding past at a constant rate. Palettes are defined in the stylesheet with a lighter set under the dark theme. A small padding keeps descenders inside the clip, decoration-break: clone keeps the gradient whole across line breaks, and selection falls back to solid text.

Use it for

  • One key phrase in a hero headline.
  • Large figures or short labels that should feel special.

Look elsewhere when

  • Body text or anything long: gradients make reading harder.
  • More than one or two places per screen.

Usage

import { GradientText } from './GradientText.jsx'

export function Hero() {
  return (
    <h1>
      Write it once. <GradientText palette="aurora" speed={8}>Find it forever.</GradientText>
    </h1>
  )
}

// Your own colours: <GradientText colors={['#0ea5e9', '#a855f7']}>…</GradientText>

Props

PropTypeDefaultWhat it does
childrenReactNode—The text.
palette'aurora' | 'dusk' | 'ocean' | 'ink''aurora'Named palette with a lighter set for the dark theme.
colorsstring[]—Your own colours (two or more); the first repeats at the end so the loop is seamless.
speednumber8Seconds for one sweep (minimum 2).
anglenumber100Gradient angle in degrees.
animatebooleantrueSet false for a still gradient.
asElementType'span'Element to render.

Accessibility

  • The text stays real text: selectable, translatable and read by screen readers exactly as written.
  • Each palette keeps its darkest stops dark enough on light surfaces, and the dark-theme set is lighter, so large text stays above 3:1 throughout the cycle.
  • Selected text turns solid for legibility; forced-colors mode shows plain text in the system colour.
  • Reduced motion stops the flow and keeps a still gradient.

Motion

The gradient drifts across in 8s (adjustable) with an ease-in-out and reverses, so it never jumps.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

GradientText.jsxgradient-text.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Text motion
Morphing text comes with Pro. Its preview shows once you unlock it.
Scramble text comes with Pro. Its preview shows once you unlock it.