Text FX JS behaviour

Flowing gradient text

A headline whose colour rivers through the letters: a symmetric gradient sits under background-clip: text ink, a slider bends the flow speed and one swatch flips the palette — with the two-line and subtitle siblings standing right beside it.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

A headline that never sits still

The symmetric gradient (colour out and back) runs under background-clip: text ink, so the loop closes without a seam. Title, second line and the subtitle below it are one family — only the size changes.

Meridian Pay · now generally available

Payments that flow
in 40 markets

One dashboard for every currency you settle — live reconciliation included.

Frankfurt · EU Dublin · EU Singapore · APAC

One lap

The family at every scale

The same two rules — clip the gradient to the glyphs, drift the background — from an 800-weight display line down to a 700-weight eyebrow.

Borderless payouts display · 800 · clamp(1.7rem, 6vw, 2.6rem)
Settle in EUR, USD, SGD and 37 more subtitle · 700 · inherits size

Important props

Important props
Prop Type Default What it does
background-clip technique 'text' The gradient is clipped onto the glyphs themselves (with the -webkit- prefix) while color turns transparent; supported by every modern browser.
--tgf-dur time '8s' One full lap of the flow; the 0.5–3× speed slider divides it (4s down to 16s).
palette attribute 'aurora' Four presets — aurora, sunset, ocean, neon — swapped through data-pal on the root, feeding their three colours into the gradient.
seamless loop technique '200%' The gradient is symmetric (stops mirror back to the start) over a 200%-wide background, so the -200% shift is exactly one tile and the loop is seamless.
reduced-motion media 'static' Under prefers-reduced-motion the animation stops and the gradient rests, fully visible and static.

Snippet

<div class="tgf" x-data="{ speed: 1, pal: 'aurora' }" x-bind:data-pal="pal"
     :style="`--tgf-dur: ${(8 / speed).toFixed(2)}s`">
    <p class="tgf-kicker">Meridian Pay · general availability</p>
    <h2 class="tgf-flow">Payments that flow</h2>
    <p class="tgf-flow tgf-sub">One dashboard · Frankfurt, Dublin, Singapore</p>

    <label class="tgf-ctl">
        <span>Flow speed</span>
        <input type="range" min="0.5" max="3" step="0.25" x-model.number="speed">
    </label>
    <div class="tgf-swatches" role="group" aria-label="Colour palette">
        <button type="button" class="tgf-sw" data-p="aurora" x-on:click="pal = 'aurora'">Aurora</button>
        <button type="button" class="tgf-sw" data-p="sunset" x-on:click="pal = 'sunset'">Sunset</button>
        <button type="button" class="tgf-sw" data-p="neon" x-on:click="pal = 'neon'">Neon</button>
    </div>
</div>

<style>
.tgf { display: grid; gap: .9rem; justify-items: center; text-align: center; }
.tgf[data-pal='aurora'] { --tgf-c1: #22d3ee; --tgf-c2: #a78bfa; --tgf-c3: #f472b6; }
.tgf[data-pal='sunset'] { --tgf-c1: #fbbf24; --tgf-c2: #fb7185; --tgf-c3: #e879f9; }
.tgf[data-pal='neon']   { --tgf-c1: #4ade80; --tgf-c2: #22d3ee; --tgf-c3: #818cf8; }
.tgf-flow {
    margin: 0; font-weight: 800; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.15;
    background: linear-gradient(100deg, var(--tgf-c1), var(--tgf-c2), var(--tgf-c3), var(--tgf-c2), var(--tgf-c1));
    background-size: 200% auto;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: tgf-move var(--tgf-dur, 8s) linear infinite;
}
.tgf-sub { font-size: .95rem; }
@keyframes tgf-move { to { background-position: -200% center; } }
@media (prefers-reduced-motion: reduce) { .tgf-flow { animation: none; } }
</style>
// app/Pages/Launch.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import GradientFlow from '@/components/GradientFlow';

export default function Launch() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <GradientFlow />
      </main>
    </NabuXUIProvider>
  );
}
// GradientFlow.jsx — a gradient that rivers through the letters
import { useState } from 'react';
import '@nabuxai/ui-core/css';

const PALETTES = {
  aurora: ['#22d3ee', '#a78bfa', '#f472b6'],
  sunset: ['#fbbf24', '#fb7185', '#e879f9'],
  neon: ['#4ade80', '#22d3ee', '#818cf8'],
};

export default function GradientFlow() {
  const [speed, setSpeed] = useState(1);
  const [pal, setPal] = useState('aurora');
  const [c1, c2, c3] = PALETTES[pal];

  return (
    <>
      <style>{`
        .tgf { display: grid; gap: .9rem; justify-items: center; text-align: center; }
        .tgf-flow {
          margin: 0; font-weight: 800; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.15;
          background: linear-gradient(100deg, ${c1}, ${c2}, ${c3}, ${c2}, ${c1});
          background-size: 200% auto;
          -webkit-background-clip: text; background-clip: text; color: transparent;
          animation: tgf-move ${(8 / speed).toFixed(2)}s linear infinite;
        }
        .tgf-sub { font-size: .95rem; }
        .tgf-ctl { display: inline-flex; gap: .6rem; align-items: center; font-size: .85rem; }
        .tgf-sw { padding: .35rem .9rem; border: 1px solid #e7e5e4; border-radius: 999px;
                  background: transparent; cursor: pointer; font-size: .8rem; }
        .tgf-sw[aria-pressed='true'] { border-color: ${c2}; color: ${c2}; }
        @keyframes tgf-move { to { background-position: -200% center; } }
        @media (prefers-reduced-motion: reduce) { .tgf-flow { animation: none; } }
      `}</style>
      <div className="tgf">
        <p className="tgf-kicker">Meridian Pay · general availability</p>
        <h2 className="tgf-flow">Payments that flow</h2>
        <p className="tgf-flow tgf-sub">One dashboard · Frankfurt, Dublin, Singapore</p>
        <label className="tgf-ctl">
          <span>Flow speed</span>
          <input type="range" min="0.5" max="3" step="0.25" value={speed}
                 onChange={(e) => setSpeed(Number(e.target.value))} />
        </label>
        <div className="tgf-swatches" role="group" aria-label="Colour palette">
          {Object.keys(PALETTES).map((p) => (
            <button type="button" key={p} className="tgf-sw" aria-pressed={pal === p}
                    onClick={() => setPal(p)}>{p}</button>
          ))}
        </div>
      </div>
    </>
  );
}
<!-- GradientFlow.vue — a gradient that rivers through the letters -->
<script setup lang="ts">
import { computed, ref } from 'vue';
import '@nabuxai/ui-core/css';

const PALETTES: Record<string, string[]> = {
  aurora: ['#22d3ee', '#a78bfa', '#f472b6'],
  sunset: ['#fbbf24', '#fb7185', '#e879f9'],
  neon: ['#4ade80', '#22d3ee', '#818cf8'],
};
const speed = ref(1);
const pal = ref('aurora');
const [c1, c2, c3] = computed(() => PALETTES[pal.value]).value;
const dur = computed(() => `${(8 / speed.value).toFixed(2)}s`);
const gradient = computed(
  () => `linear-gradient(100deg, ${c1}, ${c2}, ${c3}, ${c2}, ${c1})`,
);
</script>

<template>
  <div class="tgf">
    <p class="tgf-kicker">Meridian Pay · general availability</p>
    <h2 class="tgf-flow" :style="{ background: gradient, animationDuration: dur }">Payments that flow</h2>
    <p class="tgf-flow tgf-sub" :style="{ background: gradient, animationDuration: dur }">
      One dashboard · Frankfurt, Dublin, Singapore
    </p>
    <label class="tgf-ctl">
      <span>Flow speed</span>
      <input v-model.number="speed" type="range" min="0.5" max="3" step="0.25" />
    </label>
    <div class="tgf-swatches" role="group" aria-label="Colour palette">
      <button v-for="(colors, name) in PALETTES" :key="name" type="button" class="tgf-sw"
              :aria-pressed="pal === name" @click="pal = name">{{ name }}</button>
    </div>
  </div>
</template>

<style scoped>
.tgf { display: grid; gap: .9rem; justify-items: center; text-align: center; }
.tgf-flow {
  margin: 0; font-weight: 800; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.15;
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: tgf-move 8s linear infinite;
}
.tgf-sub { font-size: .95rem; }
.tgf-ctl { display: inline-flex; gap: .6rem; align-items: center; font-size: .85rem; }
.tgf-sw { padding: .35rem .9rem; border: 1px solid #e7e5e4; border-radius: 999px;
          background: transparent; cursor: pointer; font-size: .8rem; }
.tgf-sw[aria-pressed='true'] { border-color: #a78bfa; color: #a78bfa; }
@keyframes tgf-move { to { background-position: -200% center; } }
@media (prefers-reduced-motion: reduce) { .tgf-flow { animation: none; } }
</style>
<!-- GradientFlow.svelte — a gradient that rivers through the letters -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  const PALETTES: Record<string, string[]> = {
    aurora: ['#22d3ee', '#a78bfa', '#f472b6'],
    sunset: ['#fbbf24', '#fb7185', '#e879f9'],
    neon: ['#4ade80', '#22d3ee', '#818cf8'],
  };
  let speed = $state(1);
  let pal = $state('aurora');
  const [c1, c2, c3] = $derived(PALETTES[pal]);
  const dur = $derived(`${(8 / speed).toFixed(2)}s`);
  const gradient = $derived(`linear-gradient(100deg, ${c1}, ${c2}, ${c3}, ${c2}, ${c1})`);
</script>

<div class="tgf">
  <p class="tgf-kicker">Meridian Pay · general availability</p>
  <h2 class="tgf-flow" style={`background: ${gradient}; animation-duration: ${dur}`}>Payments that flow</h2>
  <p class="tgf-flow tgf-sub" style={`background: ${gradient}; animation-duration: ${dur}`}>
    One dashboard · Frankfurt, Dublin, Singapore
  </p>
  <label class="tgf-ctl">
    <span>Flow speed</span>
    <input type="range" min="0.5" max="3" step="0.25" bind:value={speed} oninput={(e) => (speed = Number(e.currentTarget.value))} />
  </label>
  <div class="tgf-swatches" role="group" aria-label="Colour palette">
    {#each Object.entries(PALETTES) as [name] (name)}
      <button type="button" class="tgf-sw" aria-pressed={pal === name} onclick={() => (pal = name)}>{name}</button>
    {/each}
  </div>
</div>

<style>
.tgf { display: grid; gap: .9rem; justify-items: center; text-align: center; }
.tgf-flow {
  margin: 0; font-weight: 800; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.15;
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: tgf-move 8s linear infinite;
}
.tgf-sub { font-size: .95rem; }
.tgf-ctl { display: inline-flex; gap: .6rem; align-items: center; font-size: .85rem; }
.tgf-sw { padding: .35rem .9rem; border: 1px solid #e7e5e4; border-radius: 999px;
          background: transparent; cursor: pointer; font-size: .8rem; }
.tgf-sw[aria-pressed='true'] { border-color: #a78bfa; color: #a78bfa; }
@keyframes tgf-move { to { background-position: -200% center; } }
@media (prefers-reduced-motion: reduce) { .tgf-flow { animation: none; } }
</style>