Pure TailwindMIT licensed

Tailwind Gradient Text on Multiline Paragraph

How gradient text behaves when it wraps — demonstrated, not just described. An editorial article sets a multiline gradient headline and blockquote, then puts the two models side by side: one gradient across the whole block, versus box-decoration-clone giving every line its own full ramp.

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-19 w-full min-h-svh bg-ttg19-bg font-ttg19-serif text-ttg19-ink" aria-labelledby="ttg19-title">
  <article class="mx-auto max-w-2xl px-6 py-16">
    <p class="font-ttg19-sans text-xs font-semibold tracking-[0.14em] text-ttg19-mut uppercase">Technique spotlight</p>
    <h1 id="ttg19-title" class="mt-5 bg-linear-110 from-ttg19-a via-ttg19-b to-ttg19-c bg-clip-text pb-[0.06em] text-[clamp(2.1rem,5.6vw,3.25rem)] leading-[1.14] font-semibold tracking-[-0.02em] text-transparent text-balance">Design is not just what it looks like — it's how it works.</h1>
    <p class="mt-6 font-ttg19-sans text-[15.5px]/[1.75] text-ttg19-mut text-pretty">When a gradient is applied to a multiline element, the background covers the element's whole box, so each line samples a different section of the ramp.</p>
    <blockquote class="mt-8 flex gap-5">
      <span aria-hidden="true" class="w-[3px] flex-none rounded-full bg-linear-to-b from-ttg19-a to-ttg19-c"></span>
      <p class="bg-linear-110 from-ttg19-a via-ttg19-b to-ttg19-c to-90% bg-clip-text text-[19px]/[1.65] text-transparent italic">A <code class="rounded bg-ttg19-a/8 px-1.5 py-0.5 font-ttg19-mono text-[0.78em] text-ttg19-b not-italic">linear-gradient(to right)</code> stretches across the widest line — narrower lines sample only part of it, which is why a short last line ends in a different hue.</p>
    </blockquote>
    <div class="mt-12 grid gap-4 font-ttg19-sans sm:grid-cols-2">
      <figure class="rounded-2xl border border-ttg19-line bg-white p-5">
        <figcaption class="font-ttg19-mono text-[11.5px] text-ttg19-mut">block · one gradient for the box</figcaption>
        <p class="mt-3 bg-linear-to-r from-ttg19-a to-ttg19-c bg-clip-text text-[19px]/[1.5] font-bold text-transparent">Every line shares one ramp, so the last short line stops partway.</p>
      </figure>
      <figure class="rounded-2xl border border-ttg19-line bg-white p-5">
        <figcaption class="font-ttg19-mono text-[11.5px] text-ttg19-mut">inline · box-decoration-clone</figcaption>
        <p class="mt-3 text-[19px]/[1.5] font-bold"><span class="bg-linear-to-r from-ttg19-a to-ttg19-c bg-clip-text box-decoration-clone text-transparent">Every line gets its own full ramp, start to finish, however short.</span></p>
      </figure>
    </div>
  </article>
</section>
@import "tailwindcss";

@theme {
  --color-ttg19-bg: #fbfaf8;
  --color-ttg19-bg: oklch(0.985 0.003 80);
  --color-ttg19-ink: #1c1917;
  --color-ttg19-ink: oklch(0.22 0.006 60);
  --color-ttg19-mut: #615a55;
  --color-ttg19-mut: oklch(0.47 0.012 55);
  --color-ttg19-line: #e9e5e1;
  --color-ttg19-line: oklch(0.925 0.008 60);
  --color-ttg19-a: #4338ca;
  --color-ttg19-a: oklch(0.46 0.21 277);
  --color-ttg19-b: #7c3aed;
  --color-ttg19-b: oklch(0.54 0.25 293);
  --color-ttg19-c: #a21caf;
  --color-ttg19-c: oklch(0.52 0.23 322);
  --font-ttg19-serif: 'Newsreader', Georgia, serif;
  --font-ttg19-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-ttg19-mono: 'JetBrains Mono', ui-monospace, monospace;
}

.ttg-19 {
  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-ttg19-bg: #fbfaf8;
  --color-ttg19-bg: oklch(0.985 0.003 80);
  --color-ttg19-ink: #1c1917;
  --color-ttg19-ink: oklch(0.22 0.006 60);
  --color-ttg19-mut: #615a55;
  --color-ttg19-mut: oklch(0.47 0.012 55);
  --color-ttg19-line: #e9e5e1;
  --color-ttg19-line: oklch(0.925 0.008 60);
  --color-ttg19-a: #4338ca;
  --color-ttg19-a: oklch(0.46 0.21 277);
  --color-ttg19-b: #7c3aed;
  --color-ttg19-b: oklch(0.54 0.25 293);
  --color-ttg19-c: #a21caf;
  --color-ttg19-c: oklch(0.52 0.23 322);
  --font-ttg19-serif: 'Newsreader', Georgia, serif;
  --font-ttg19-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-ttg19-mono: 'JetBrains Mono', ui-monospace, monospace;
}

.ttg-19 {
  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=Newsreader:ital,opsz,wght@0,6..72,400..700;1,6..72,400..600&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@500&display=swap">

What changed in the port

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

  • border-image on the quote became a rounded gradient rail span; -webkit-text-fill-color overrides on inline code became a plain colour utility.
  • Content upgrade: the original only described per-line gradients; the port demonstrates both models side by side, including box-decoration-clone.
  • UI upgrade: Newsreader's optical-size serif, text-balance on the headline and muted copy raised from 4.3:1 to 7.2: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 Gradient Text on Multiline Paragraph
Source: https://codefronts.com/motion/tailwind-css-text-gradient/tailwind-gradient-text-on-multiline-paragraph/

How gradient text behaves when it wraps &mdash; demonstrated, not just described. An editorial article sets a multiline gradient headline and blockquote, then puts the two models side by side: one gradient across the whole block, versus box-decoration-clone giving every line its own full ramp.
## HTML
```html
<section class="ttg-19 w-full min-h-svh bg-ttg19-bg font-ttg19-serif text-ttg19-ink" aria-labelledby="ttg19-title">
  <article class="mx-auto max-w-2xl px-6 py-16">
    <p class="font-ttg19-sans text-xs font-semibold tracking-[0.14em] text-ttg19-mut uppercase">Technique spotlight</p>
    <h1 id="ttg19-title" class="mt-5 bg-linear-110 from-ttg19-a via-ttg19-b to-ttg19-c bg-clip-text pb-[0.06em] text-[clamp(2.1rem,5.6vw,3.25rem)] leading-[1.14] font-semibold tracking-[-0.02em] text-transparent text-balance">Design is not just what it looks like — it's how it works.</h1>
    <p class="mt-6 font-ttg19-sans text-[15.5px]/[1.75] text-ttg19-mut text-pretty">When a gradient is applied to a multiline element, the background covers the element's whole box, so each line samples a different section of the ramp.</p>
    <blockquote class="mt-8 flex gap-5">
      <span aria-hidden="true" class="w-[3px] flex-none rounded-full bg-linear-to-b from-ttg19-a to-ttg19-c"></span>
      <p class="bg-linear-110 from-ttg19-a via-ttg19-b to-ttg19-c to-90% bg-clip-text text-[19px]/[1.65] text-transparent italic">A <code class="rounded bg-ttg19-a/8 px-1.5 py-0.5 font-ttg19-mono text-[0.78em] text-ttg19-b not-italic">linear-gradient(to right)</code> stretches across the widest line — narrower lines sample only part of it, which is why a short last line ends in a different hue.</p>
    </blockquote>
    <div class="mt-12 grid gap-4 font-ttg19-sans sm:grid-cols-2">
      <figure class="rounded-2xl border border-ttg19-line bg-white p-5">
        <figcaption class="font-ttg19-mono text-[11.5px] text-ttg19-mut">block · one gradient for the box</figcaption>
        <p class="mt-3 bg-linear-to-r from-ttg19-a to-ttg19-c bg-clip-text text-[19px]/[1.5] font-bold text-transparent">Every line shares one ramp, so the last short line stops partway.</p>
      </figure>
      <figure class="rounded-2xl border border-ttg19-line bg-white p-5">
        <figcaption class="font-ttg19-mono text-[11.5px] text-ttg19-mut">inline · box-decoration-clone</figcaption>
        <p class="mt-3 text-[19px]/[1.5] font-bold"><span class="bg-linear-to-r from-ttg19-a to-ttg19-c bg-clip-text box-decoration-clone text-transparent">Every line gets its own full ramp, start to finish, however short.</span></p>
      </figure>
    </div>
  </article>
</section>
```
## CSS
```css
@import "tailwindcss";

@theme {
  --color-ttg19-bg: #fbfaf8;
  --color-ttg19-bg: oklch(0.985 0.003 80);
  --color-ttg19-ink: #1c1917;
  --color-ttg19-ink: oklch(0.22 0.006 60);
  --color-ttg19-mut: #615a55;
  --color-ttg19-mut: oklch(0.47 0.012 55);
  --color-ttg19-line: #e9e5e1;
  --color-ttg19-line: oklch(0.925 0.008 60);
  --color-ttg19-a: #4338ca;
  --color-ttg19-a: oklch(0.46 0.21 277);
  --color-ttg19-b: #7c3aed;
  --color-ttg19-b: oklch(0.54 0.25 293);
  --color-ttg19-c: #a21caf;
  --color-ttg19-c: oklch(0.52 0.23 322);
  --font-ttg19-serif: 'Newsreader', Georgia, serif;
  --font-ttg19-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-ttg19-mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

How this works

Two models. On a block element the gradient is sized to the whole box, so each line samples a slice and short lines end early in the ramp. On an inline element the default slice behaviour does the same across the combined fragments — but box-decoration-clone repaints the background per line:

<span class="bg-linear-to-r from-ttg19-a to-ttg19-c bg-clip-text text-transparent
  box-decoration-clone">…</span>

Clone mode means every line runs the full indigo → magenta ramp, which suits pull quotes; the block model gives one continuous sweep, which suits headlines.

Diagonal angles (110°) shift colour vertically too, so even lines of equal length look distinct.

Make it yours

  • Uniform hue per line: bg-[length:200%_100%] bg-center on the block.
  • Steeper shift between lines: bg-linear-135.
  • Readable body text: keep gradients to headlines and quotes; long paragraphs in gradient ink tire the eye.
  • Highlighter look: use clone mode without bg-clip-text for per-line marker backgrounds.

Gotchas — read before shipping

  • overflow-hidden on gradient text crops descenders — use bottom padding instead.
  • Inline code inside a gradient paragraph inherits the transparent fill; reset it with text-ttg19-b and its own background, as in the quote here.
  • box-decoration-clone also clones padding and border-radius per line — useful, but surprising if you didn't expect it.

Browser support

ChromeSafariFirefoxEdge
111+16.4+128+111+

box-decoration-break: clone is unprefixed in Chrome 130+ and Firefox; Tailwind adds -webkit-box-decoration-break for Safari.

Techniques used in this demo

Utilitiesfirst-class utility or variant

Search CodeFronts

Loading…