Pure TailwindMIT licensed

Tailwind Rainbow Gradient Text (Multi-Color)

A full-spectrum rainbow from two colour stops. v4's /longer interpolation modifier tells the gradient to travel the long way round the oklch hue wheel, so from-ttg15-start to-ttg15-start sweeps all 360°. The animated twin loops seamlessly, and the tag cloud gets matching gradient borders.

Live Demo
Plain CSSTailwind v4
Try it

Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time

Untitled UI React · Affiliate link

Get Untitled UI Pro

The code

<section class="ttg-15 w-full min-h-svh grid place-items-center bg-ttg15-bg px-5 py-16 font-ttg15-sans text-ttg15-ink" aria-label="Rainbow gradient text demo">
  <div class="grid w-full max-w-3xl justify-items-center text-center">
    <h1 class="w-fit bg-linear-to-r/longer from-ttg15-start to-ttg15-start bg-clip-text pb-[0.06em] text-[clamp(3.25rem,11vw,6.75rem)] leading-none font-extrabold tracking-[-0.045em] text-transparent">Spectacular</h1>
    <p class="mt-1 w-fit bg-linear-to-r/longer from-ttg15-start to-ttg15-start bg-[length:200%_100%] bg-clip-text pb-[0.06em] text-[clamp(2rem,6.5vw,4rem)] leading-none font-extrabold tracking-[-0.04em] text-transparent animate-ttg15-flow motion-reduce:animate-none">Iridescent</p>
    <ul class="mt-10 flex flex-wrap justify-center gap-2.5" aria-label="Topics">
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h1),var(--color-ttg15-h2))_border-box]">Design</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h2),var(--color-ttg15-h3))_border-box]">Colour</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h3),var(--color-ttg15-h4))_border-box]">Motion</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h4),var(--color-ttg15-h5))_border-box]">Type</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h5),var(--color-ttg15-h1))_border-box]">Play</li>
    </ul>
    <p class="mt-8 max-w-md text-[14.5px]/[1.7] text-ttg15-mut text-pretty">Two identical stops plus <code class="rounded bg-white/8 px-1.5 py-0.5 font-ttg15-mono text-[12.5px] text-ttg15-ink">/longer</code> make the gradient travel the long way round the oklch hue wheel &mdash; a full, evenly lit spectrum.</p>
  </div>
</section>
@import "tailwindcss";

@theme {
  --color-ttg15-bg: #07050c;
  --color-ttg15-bg: oklch(0.13 0.012 295);
  --color-ttg15-ink: #f1eff6;
  --color-ttg15-ink: oklch(0.96 0.008 295);
  --color-ttg15-mut: #a7a3b4;
  --color-ttg15-mut: oklch(0.75 0.018 295);
  --color-ttg15-start: #ff6b6b;
  --color-ttg15-start: oklch(0.75 0.17 25);
  --color-ttg15-h1: #ff6f6a;
  --color-ttg15-h1: oklch(0.72 0.18 25);
  --color-ttg15-h2: #e7b23b;
  --color-ttg15-h2: oklch(0.8 0.15 85);
  --color-ttg15-h3: #3fcf8e;
  --color-ttg15-h3: oklch(0.77 0.16 155);
  --color-ttg15-h4: #4aa3ff;
  --color-ttg15-h4: oklch(0.7 0.16 250);
  --color-ttg15-h5: #c070ff;
  --color-ttg15-h5: oklch(0.7 0.2 310);
  --font-ttg15-sans: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-ttg15-mono: 'Geist Mono', ui-monospace, monospace;
  --animate-ttg15-flow: ttg15-flow 5s linear infinite;

  @keyframes ttg15-flow {
    from {
      background-position: 0% 50%;
    }

    to {
      background-position: 200% 50%;
    }
  }
}

.ttg-15 {
  width: 100%;
  min-height: 100svh;
}

Setup — do this once per project

Skip this if your project already runs Tailwind v4.

1Load Tailwind
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

Compiles in the browser — perfect for a CodePen or a quick test, not for production.

2Add the stylesheetRequiredthe @theme block is what makes the custom utilities exist
@import "tailwindcss";

@theme {
  --color-ttg15-bg: #07050c;
  --color-ttg15-bg: oklch(0.13 0.012 295);
  --color-ttg15-ink: #f1eff6;
  --color-ttg15-ink: oklch(0.96 0.008 295);
  --color-ttg15-mut: #a7a3b4;
  --color-ttg15-mut: oklch(0.75 0.018 295);
  --color-ttg15-start: #ff6b6b;
  --color-ttg15-start: oklch(0.75 0.17 25);
  --color-ttg15-h1: #ff6f6a;
  --color-ttg15-h1: oklch(0.72 0.18 25);
  --color-ttg15-h2: #e7b23b;
  --color-ttg15-h2: oklch(0.8 0.15 85);
  --color-ttg15-h3: #3fcf8e;
  --color-ttg15-h3: oklch(0.77 0.16 155);
  --color-ttg15-h4: #4aa3ff;
  --color-ttg15-h4: oklch(0.7 0.16 250);
  --color-ttg15-h5: #c070ff;
  --color-ttg15-h5: oklch(0.7 0.2 310);
  --font-ttg15-sans: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-ttg15-mono: 'Geist Mono', ui-monospace, monospace;
  --animate-ttg15-flow: ttg15-flow 5s linear infinite;

  @keyframes ttg15-flow {
    from {
      background-position: 0% 50%;
    }

    to {
      background-position: 200% 50%;
    }
  }
}

.ttg-15 {
  width: 100%;
  min-height: 100svh;
}
3Fonts used by this demooptional — skip if you have your own type stack
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500..800&family=Geist+Mono:wght@500&display=swap">

What changed in the port

Which parts became utilities, which stayed CSS, and why.

  • The original's six- and seven-stop HSL gradients became bg-linear-to-r/longer with two identical stops — v4's interpolation modifier does the hue walk.
  • UI upgrade: oklch keeps every hue at equal perceived lightness, removing the glaring green and dim blue bands of the HSL version.
  • UI upgrade: tag chips got real gradient borders with readable white labels (the original's gradient-text chips with a 30% currentColor border were nearly invisible), and muted copy rose from 3.4:1 to 8:1.
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS demo from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Tailwind Rainbow Gradient Text (Multi-Color)
Source: https://codefronts.com/motion/tailwind-css-text-gradient/tailwind-rainbow-gradient-text-multi-color/

A full-spectrum rainbow from two colour stops. v4's /longer interpolation modifier tells the gradient to travel the long way round the oklch hue wheel, so from-ttg15-start to-ttg15-start sweeps all 360°. The animated twin loops seamlessly, and the tag cloud gets matching gradient borders.
## HTML
```html
<section class="ttg-15 w-full min-h-svh grid place-items-center bg-ttg15-bg px-5 py-16 font-ttg15-sans text-ttg15-ink" aria-label="Rainbow gradient text demo">
  <div class="grid w-full max-w-3xl justify-items-center text-center">
    <h1 class="w-fit bg-linear-to-r/longer from-ttg15-start to-ttg15-start bg-clip-text pb-[0.06em] text-[clamp(3.25rem,11vw,6.75rem)] leading-none font-extrabold tracking-[-0.045em] text-transparent">Spectacular</h1>
    <p class="mt-1 w-fit bg-linear-to-r/longer from-ttg15-start to-ttg15-start bg-[length:200%_100%] bg-clip-text pb-[0.06em] text-[clamp(2rem,6.5vw,4rem)] leading-none font-extrabold tracking-[-0.04em] text-transparent animate-ttg15-flow motion-reduce:animate-none">Iridescent</p>
    <ul class="mt-10 flex flex-wrap justify-center gap-2.5" aria-label="Topics">
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h1),var(--color-ttg15-h2))_border-box]">Design</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h2),var(--color-ttg15-h3))_border-box]">Colour</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h3),var(--color-ttg15-h4))_border-box]">Motion</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h4),var(--color-ttg15-h5))_border-box]">Type</li>
      <li class="rounded-full border-[1.5px] border-transparent px-4 py-1.5 text-sm font-bold [background:linear-gradient(var(--color-ttg15-bg),var(--color-ttg15-bg))_padding-box,linear-gradient(90deg_in_oklch,var(--color-ttg15-h5),var(--color-ttg15-h1))_border-box]">Play</li>
    </ul>
    <p class="mt-8 max-w-md text-[14.5px]/[1.7] text-ttg15-mut text-pretty">Two identical stops plus <code class="rounded bg-white/8 px-1.5 py-0.5 font-ttg15-mono text-[12.5px] text-ttg15-ink">/longer</code> make the gradient travel the long way round the oklch hue wheel &mdash; a full, evenly lit spectrum.</p>
  </div>
</section>
```
## CSS
```css
@import "tailwindcss";

@theme {
  --color-ttg15-bg: #07050c;
  --color-ttg15-bg: oklch(0.13 0.012 295);
  --color-ttg15-ink: #f1eff6;
  --color-ttg15-ink: oklch(0.96 0.008 295);
  --color-ttg15-mut: #a7a3b4;
  --color-ttg15-mut: oklch(0.75 0.018 295);
  --color-ttg15-start: #ff6b6b;
  --color-ttg15-start: oklch(0.75 0.17 25);
  --color-ttg15-h1: #ff6f6a;
  --color-ttg15-h1: oklch(0.72 0.18 25);
  --color-ttg15-h2: #e7b23b;
  --color-ttg15-h2: oklch(0.8 0.15 85);
  --color-ttg15-h3: #3fcf8e;
  --color-ttg15-h3: oklch(0.77 0.16 155);
  --color-ttg15-h4: #4aa3ff;
  --color-ttg15-h4: oklch(0.7 0.16 250);
  --color-ttg15-h5: #c070ff;
  --color-ttg15-h5: oklch(0.7 0.2 310);
  --font-ttg15-sans: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-ttg15-mono: 'Geist Mono', ui-monospace, monospace;
  --animate-ttg15-flow: ttg15-flow 5s linear infinite;

  @keyframes ttg15-flow {
    from {
      background-position: 0% 50%;
    }

    to {
      background-position: 200% 50%;
    }
  }
}

.ttg-15 {
  width: 100%;
  min-height: 100svh;
}
```

How this works

Two stops, every hue. Gradient interpolation in a polar colour space can go the short or the long way between hues. Same start and end colour + longer = one full lap:

<h1 class="bg-linear-to-r/longer from-ttg15-start to-ttg15-start
  bg-clip-text text-transparent">Spectacular</h1>

This compiles to linear-gradient(to right in oklch longer hue, …). Because oklch is perceptual, every hue lands at the same perceived lightness — the original's six HSL stops had a glaring green band and a dim blue one.

Seamless loop. The animated line uses a 200% repeating tile and moves it exactly one tile per cycle.

Make it yours

  • Warm half-rainbow: bg-linear-to-r/increasing from-red-500 to-yellow-400.
  • Different start hue: change --color-ttg15-start — the whole spectrum rotates with it.
  • Pastel rainbow: raise the token's lightness to 0.85 and lower chroma to 0.1.
  • Pause on hover: hover:[animation-play-state:paused].

Gotchas — read before shipping

  • /longer only does something in polar spaces (oklch, hsl); it is a no-op on /srgb.
  • With identical start and end colours, removing /longer gives you a flat single colour — not a bug.
  • Rainbow text at body sizes is hard to read; keep it to display lines and short tags.

Browser support

ChromeSafariFirefoxEdge
111+16.4+128+111+

Hue interpolation methods (longer hue) are Chrome 111 / Safari 16.2 / Firefox 127; older engines ignore the method and render a flat colour.

Techniques used in this demo

Utilitiesfirst-class utility or variant

Plain CSSno Tailwind surface

Search CodeFronts

Loading…