# Gradient Text Animation

Motionboard shot name: Gradient Reveal

A two-line headline, Ask anything. See it answered., is revealed from left to right through a blurred edge while a blue, violet, pink and orange gradient keeps drifting through the letters. The headline shrinks up, a search box types a query under it, and the answer's first line arrives with the same sweep before the Lumen lockup.

- Position in a launch film: Opening
- Slug: gradient-text-animation
- Preview video: https://media.motionboard.app/gradient-reveal.mp4
- Recipe page: https://motionboard.app/recipes/gradient-text-animation/
- License: MIT. Free to use in your own projects, including commercial launch films. https://github.com/krisyangdev/motionboard/blob/main/LICENSE

## How to use this recipe

You are a coding agent. The user wants this shot for their own product. Follow these steps.

1. **Know the product.** If the product is clear from the user's repo or conversation, ask nothing and start. Otherwise ask once for: product name, logo file, brand colors.
2. **Pick the output.** If the user's message says a video or their website, do that. Otherwise ask once which one they want.
   - **Video (HyperFrames).** Create a folder named `gradient-reveal`. Download every file under "Source files" below with the curl commands, keeping relative paths. Adapt `index.html` (see "What to adapt"). Run `npx --yes hyperframes@0.8.209 check` on the untouched copy first and note its result. Preview with `npx --yes hyperframes@0.8.209 preview`, render an MP4 with `npx --yes hyperframes@0.8.209 render` (into `renders/`, named with a timestamp). The same commands are in `package.json` as `dev`, `check`, `render`; pass flags after `--`, as in `npm run render -- --quality draft`. Rendering needs network access for web fonts and GSAP.
   - **Website motion.** Port the GSAP timeline in `index.html` into the user's site, using their stack (React, Vue, Svelte, plain HTML). Build the same DOM structure, keep the timeline's durations, delays and easings exactly, and start it when the element scrolls into view (IntersectionObserver or ScrollTrigger). Respect `prefers-reduced-motion: reduce`: show the final frame as a static state and skip the movement.
3. **What to adapt.**
   - **Brand layer** (product name, logo, colors, fonts, copy): replace directly with the user's.
   - **UI layer** (the product screens, cards, windows, controls shown in the shot): rebuild the user's real UI as clean DOM, from their codebase (components, design tokens) or from a screenshot used as reference only. Never paste a screenshot into the shot.
   - **Motion** (timing, easing, camera moves, layering, stagger, order of events): keep exactly as in the source. This is what the recipe is.
   - The timeline targets UI elements by id and class, and camera moves land on fixed coordinates. Keep the ids the timeline uses, keep row counts and text lengths close to the source, and when the layout moves, update the target coordinates without changing the times.
4. **Fonts.** HyperFrames fetches Google Fonts such as Inter on its own. Some sources use macOS local fonts (PingFang, Songti via `local()`). Use the user's brand font when it can be bundled; for a system font such as SF Pro, use Inter. Check that text still fits its boxes.
5. **Verify.** Compare the render with the preview video above at the beat times in the Timing row. The beats, timing and camera should match; only brand and UI content differ.

## Spec

| Item | Value |
| --- | --- |
| Timing | Film 11s. Line 1 revealed 0.3–1.5s and line 2 0.6–1.8s (1.2s each); hold with the gradient drifting 1.8–2.9s; headline shrinks up 2.9–3.6s; search pill rises 3.5–4.05s; query typed 4.0–4.9s; send button pulses 5.0–5.45s; answer line sweeps in 5.1–6.3s; body text 5.8–6.4s; three source chips 6.1–6.84s (0.12s stagger); scene fades out 7.8–8.15s; lockup 8.15–8.8s and holds still to 11s (2.2s) |
| Easing | Both headline reveals and the answer reveal use power2.inOut; the shrink uses power3.inOut; the search pill rises with expo.out; typing uses power1.inOut; the send pulse is power2.in down to 0.86 then back.out(3); body text and chips use power2.out; the scene exit uses power2.in; the lockup mark uses back.out(1.6), the wordmark expo.out and the tagline power2.out; the gradient drift and the haze drift are linear (none) |
| Camera | Locked camera, no zoom. The gradient tile is 1500px wide (640px on the wordmark) and moves one full tile every 7s, about 214px/s (91px/s on the wordmark), computed from timeline time. The three haze blobs drift linearly over the whole film by 70–180px. Each reveal clears a blur of 14px × (1 − progress)² behind the mask edge |
| Subject | Headline Ask anything. / See it answered. at 150px, weight 700, letter-spacing −0.045em, line height 1.12, centred from y=340, then scaled to 0.6 (about 90px) and moved up 284px. Search pill 1500x120px at (210, 300) with a 3px gradient border, a 46px magnifier, the query at 44px and a 78px gradient send button. Answer line Steep 1:8 in cold water, 14 hours. at 76px, weight 700, at (210, 468); body text 34px at y=592; three chips 60px high with 27px text at y=760. Lockup: 130px gradient spark mark, Lumen at 160px in the drifting gradient, tagline Search that answers. at 40px |
| Sync | The pill appears at 3.5s, 0.1s before the shrink ends at 3.6s; the caret is solid while the query types 4.0–4.9s and disappears at 5.05s; the answer sweep starts at 5.1s, the moment the send button springs back; the body text lands about halfway through the sweep and the chips follow; the lockup starts the moment the scene has finished fading, so the two never share the frame |
| Style | Background `#ffffff` with three soft radial haze blobs (blue, pink, violet at 18–28% opacity); text `#14141b`, secondary `#6b6b78`; one gradient `#3b82f6` → `#8b5cf6` → `#ec4899` → `#f97316` → `#3b82f6` used on the headline, the pill border, the send button, the answer line and the wordmark; Inter throughout, weight 700 for display text; no grain, no vignette |

## Why it works

The reveal and the colour are two separate layers, so the eye gets two kinds of motion at once. A soft edge about 120px wide crosses each line from left to right in 1.2s while the blur clears behind it, so the headline arrives like a light being switched on. Under the mask the four-colour gradient (blue, violet, pink, orange) keeps sliding across the letters at a constant speed, which keeps the headline alive during the 1.1s hold and makes the colour read as light moving through the type. The second line starts 0.3s after the first, so the sweep reads as one gesture across two lines. The same mask-and-gradient recipe returns for the answer's first line, so the viewer learns the move once and recognises it when the answer arrives. The headline shrinks up to make room for the search box, which turns the title into a header and shows what the product does: ask, then see the answer. The film is white with a faint colour haze, the gradient is the only colour, and the answer line (76px) is the largest new element in its beat.

## Prompt

> Build an 11-second, 1920x1080, 30 fps light product film called Gradient Reveal for a fictional product, Lumen (an AI search engine). White background, font Inter, one four-colour gradient #3b82f6 → #8b5cf6 → #ec4899 → #f97316 → #3b82f6 (the last stop repeats the first so the tile loops) as the only colour. Behind everything put three soft radial-gradient blobs (blue, pink, violet at 18–28% opacity, 1200px) that drift linearly over the whole film. Beat 1: a two-line headline Ask anything. / See it answered. at 150px, weight 700, letter-spacing −0.045em, line height 1.12, centred from y=340. Fill each line with the gradient using background-clip: text, a 1500px-wide background tile and 90deg stops, and move background-position-x from timeline time: x = −((t × 1500 / 7) mod 1500) px, so the colours keep sliding across the letters for the whole film. Reveal each line left to right with a mask-image linear-gradient whose edge is 120px wide: edge centre x = −60 + p × (width + 120), mask = #000 up to x − 60, transparent from x + 60. Drive p with a power2.inOut tween of 1.2s (line 1 at 0.3s, line 2 at 0.6s) and set filter: blur(14px × (1 − p)²) in the same onUpdate. Hide the lines in CSS with a fully transparent mask so the first frame is empty. Beat 2: at 2.9s scale the headline to 0.6 and move it up 284px over 0.7s (power3.inOut, transform-origin top centre). At 3.5s a 1500x120px search pill with a 3px drifting gradient border rises from 34px below (expo.out, 0.55s). It holds a 46px magnifier, the query how to make cold brew at home at 44px typed from 4.0 to 4.9s (power1.inOut, characters computed from the tween value) with a 4px caret that stays solid while typing, and a 78px gradient send button that pulses to 0.86 and back (back.out(3)) at 5.0–5.45s. At 5.1s the answer line Steep 1:8 in cold water, 14 hours. at 76px, weight 700, left x=210, y=468, sweeps in with the same gradient and mask reveal (1.2s). Body text at 34px (Use coarse-ground coffee at one part to eight parts water. Steep 12 to 16 hours in the fridge, then strain through a paper filter.) fades up at 5.8s, then three 60px source chips (brewlab.co, coffeeatlas.org, homebarista.net +3) at 27px stagger in from 6.1s with 0.12s gaps. At 7.8s fade the whole scene out over 0.35s (power2.in). Lockup from 8.15s: a 130px gradient circle with a white four-point spark, Lumen at 160px with the drifting gradient fill (640px tile), and the tagline Search that answers. at 40px in #6b6b78; mark back.out(1.6), wordmark expo.out, tagline power2.out, all settled by 8.8s and held still to 11s. Drive everything from one paused GSAP timeline; use a linear proxy tween for the gradient drift, no CSS animations.

## Often confused with

- [Blur Text Animation](https://motionboard.app/r/blur-text-animation.md): Blur Text Animation resolves each word of a line from heavy blur on a dark field; in Gradient Reveal one soft mask edge crosses the whole line from left to right while a moving four-colour gradient fills the letters.
- [Word-by-Word Text Highlight](https://motionboard.app/r/word-by-word-text-highlight.md): Word-by-Word Text Highlight brightens words from gray to white on a still line; in Gradient Reveal the line arrives left to right through a feathered edge and its colour keeps moving.

## Source files

Runnable HyperFrames project, 3 files.

- https://motionboard.app/source/gradient-reveal/hyperframes.json (318 B)
- https://motionboard.app/source/gradient-reveal/index.html (12.3 KB)
- https://motionboard.app/source/gradient-reveal/package.json (304 B)

Download all of them:

```sh
curl -fsSL --create-dirs -o "gradient-reveal/hyperframes.json" "https://motionboard.app/source/gradient-reveal/hyperframes.json"
curl -fsSL --create-dirs -o "gradient-reveal/index.html" "https://motionboard.app/source/gradient-reveal/index.html"
curl -fsSL --create-dirs -o "gradient-reveal/package.json" "https://motionboard.app/source/gradient-reveal/package.json"
```

## index.html

```html
<!doctype html>
<html lang="en" data-resolution="landscape">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=1920, height=1080" />
    <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
    <style>
      :root {
        --ink: #14141b;
        --sub: #6b6b78;
        --line: #e3e3ec;
        --blue: #3b82f6;
        --violet: #8b5cf6;
        --pink: #ec4899;
        --orange: #f97316;
        --grad: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 25%, #ec4899 50%, #f97316 75%, #3b82f6 100%);
        --font-ui: "Inter", -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
      }
      * { margin: 0; padding: 0; box-sizing: border-box; }
      html, body { width: 1920px; height: 1080px; overflow: hidden; background: #fff; }
      #root {
        position: relative; width: 1920px; height: 1080px; overflow: hidden; background: #fff;
        font-family: var(--font-ui); color: var(--ink); -webkit-font-smoothing: antialiased;
        font-feature-settings: "ss01", "cv11";
      }
      .full { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; }
      .a { position: absolute; }
      svg { display: block; flex: none; }

      /* ---------- soft colour haze behind everything ---------- */
      .blob { position: absolute; width: 1200px; height: 1200px; border-radius: 50%; }
      #b1 { left: -420px; top: -520px; background: radial-gradient(circle, rgba(120, 150, 255, 0.28) 0%, rgba(120, 150, 255, 0) 68%); }
      #b2 { left: 1180px; top: 520px; background: radial-gradient(circle, rgba(255, 150, 190, 0.26) 0%, rgba(255, 150, 190, 0) 68%); }
      #b3 { left: 1250px; top: -640px; background: radial-gradient(circle, rgba(170, 140, 255, 0.18) 0%, rgba(170, 140, 255, 0) 66%); }

      /* ---------- gradient text and gradient borders (positions driven by the timeline) ---------- */
      .gt {
        background-image: var(--grad); background-repeat: repeat-x; background-size: 1500px 100%;
        -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
        white-space: nowrap;
      }
      .gb { background-image: var(--grad); background-repeat: repeat-x; background-size: 1500px 100%; }
      /* hidden until the reveal mask opens */
      .rv {
        -webkit-mask-image: linear-gradient(90deg, transparent, transparent); mask-image: linear-gradient(90deg, transparent, transparent);
        -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
        filter: blur(14px);
      }

      /* ---------- scene 1: headline ---------- */
      #hl { left: 0; top: 340px; width: 1920px; transform-origin: 50% 0; }
      .row { display: flex; justify-content: center; }
      .ln {
        display: block; font-size: 150px; line-height: 1.12; font-weight: 700; letter-spacing: -0.045em;
        padding: 0 0.06em 0.07em;
      }

      /* ---------- search box ---------- */
      #sbox { left: 210px; top: 300px; width: 1500px; height: 120px; border-radius: 60px; padding: 3px; opacity: 0; box-shadow: 0 24px 60px rgba(100, 80, 220, 0.16), 0 3px 10px rgba(20, 20, 40, 0.06); }
      #sin { position: relative; width: 100%; height: 100%; border-radius: 57px; background: #fff; display: flex; align-items: center; padding: 0 30px 0 38px; gap: 26px; }
      #qwrap { display: flex; align-items: center; flex: 1; font-size: 44px; font-weight: 500; letter-spacing: -0.015em; color: var(--ink); white-space: pre; height: 70px; }
      #caret { display: inline-block; width: 4px; height: 56px; margin-left: 4px; border-radius: 2px; background: #4f6df5; opacity: 0; }
      #go { width: 78px; height: 78px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background-image: var(--grad); background-size: 220px 100%; background-position: 0 0; }

      /* ---------- answer ---------- */
      #a1 { left: 210px; top: 468px; font-size: 76px; line-height: 1.18; font-weight: 700; letter-spacing: -0.032em; padding-bottom: 0.08em; }
      #a2 { left: 210px; top: 592px; width: 1500px; font-size: 34px; line-height: 1.5; font-weight: 400; color: #3d3d4a; opacity: 0; letter-spacing: -0.005em; }
      #a2 b { font-weight: 600; color: var(--ink); }
      #chips { left: 210px; top: 760px; width: 1500px; display: flex; gap: 16px; }
      .chip { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 26px 0 20px; border-radius: 30px; background: #f6f6fa; border: 1.5px solid var(--line); font-size: 27px; font-weight: 500; color: #3d3d4a; white-space: nowrap; opacity: 0; }
      .chip i { display: block; width: 26px; height: 26px; border-radius: 8px; }
      .chip em { font-style: normal; color: var(--sub); font-weight: 500; }

      /* ---------- lockup ---------- */
      #lock { left: 0; top: 400px; width: 1920px; height: 180px; display: flex; align-items: center; justify-content: center; gap: 38px; }
      #mk { width: 130px; height: 130px; opacity: 0; }
      #wm { font-size: 160px; line-height: 1.12; font-weight: 700; letter-spacing: -0.045em; padding: 0 0.06em 0.07em; opacity: 0; }
      #tag { left: 0; top: 618px; width: 1920px; text-align: center; font-size: 40px; font-weight: 500; letter-spacing: -0.015em; color: var(--sub); opacity: 0; }
    </style>
  </head>
  <body>
    <div id="root" data-composition-id="main" data-start="0" data-duration="11" data-width="1920" data-height="1080">
      <div id="haze" class="clip full" data-start="0" data-duration="11" data-track-index="0" data-layout-ignore>
        <div id="b1" class="blob"></div>
        <div id="b2" class="blob"></div>
        <div id="b3" class="blob"></div>
      </div>

      <div id="s1" class="clip full" data-start="0" data-duration="8.2" data-track-index="1">
        <div id="stage1" class="full" data-layout-allow-overlap>
          <div id="hl" class="a">
            <div class="row"><span id="l1" class="ln gt rv" data-per="1500">Ask anything.</span></div>
            <div class="row"><span id="l2" class="ln gt rv" data-per="1500">See it answered.</span></div>
          </div>

          <div id="sbox" class="a gb" data-per="1500">
            <div id="sin">
              <svg width="46" height="46" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
                <circle cx="20" cy="20" r="13" stroke="#6b6b78" stroke-width="4" />
                <path d="M30 30 L40 40" stroke="#6b6b78" stroke-width="4" stroke-linecap="round" />
              </svg>
              <div id="qwrap"><span id="q"></span><span id="caret"></span></div>
              <div id="go">
                <svg width="38" height="38" viewBox="0 0 38 38" fill="none" xmlns="http://www.w3.org/2000/svg">
                  <path d="M8 19 H29 M20 10 L29 19 L20 28" stroke="#fff" stroke-width="4.2" stroke-linecap="round" stroke-linejoin="round" />
                </svg>
              </div>
            </div>
          </div>

          <div id="a1" class="a gt rv" data-per="1500">Steep 1:8 in cold water, 14 hours.</div>
          <div id="a2" class="a">Use <b>coarse-ground coffee</b> at one part to eight parts water. Steep 12 to 16 hours in the fridge, then strain through a paper filter.</div>
          <div id="chips" class="a">
            <div class="chip"><i style="background:#3b82f6"></i>brewlab.co</div>
            <div class="chip"><i style="background:#ec4899"></i>coffeeatlas.org</div>
            <div class="chip"><i style="background:#f97316"></i>homebarista.net<em>&nbsp;+3</em></div>
          </div>
        </div>
      </div>

      <div id="s2" class="clip full" data-start="8.1" data-duration="2.9" data-track-index="2">
        <div id="lock" class="a" data-layout-allow-overlap>
          <svg id="mk" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
            <defs>
              <linearGradient id="mg" x1="0" y1="0" x2="1" y2="1">
                <stop offset="0" stop-color="#3b82f6" />
                <stop offset="0.38" stop-color="#8b5cf6" />
                <stop offset="0.7" stop-color="#ec4899" />
                <stop offset="1" stop-color="#f97316" />
              </linearGradient>
            </defs>
            <circle cx="50" cy="50" r="48" fill="url(#mg)" />
            <path d="M50 17 C52 38 62 48 83 50 C62 52 52 62 50 83 C48 62 38 52 17 50 C38 48 48 38 50 17Z" fill="#fff" />
          </svg>
          <div id="wm" class="gt" data-per="640">Lumen</div>
        </div>
        <div id="tag" class="a">Search that answers.</div>
      </div>
    </div>

    <script>
      const $ = (s) => document.querySelector(s);
      const Q = "how to make cold brew at home";
      const qEl = $("#q");
      const caret = $("#caret");

      /* gradient layers: size the tile once, then drift by timeline time */
      const drifters = Array.from(document.querySelectorAll(".gt, .gb")).map((el) => {
        const per = parseFloat(el.dataset.per);
        el.style.backgroundSize = per + "px 100%";
        return { el, per };
      });
      function paint(t) {
        for (const d of drifters) {
          const off = -((t * d.per / 7) % d.per);
          d.el.style.backgroundPosition = off.toFixed(1) + "px 0";
        }
        // caret: blinks while idle, solid while typing, gone after the query is sent
        let on = 0;
        if (t >= 3.5 && t < 5.05) on = t >= 4.0 && t < 4.9 ? 1 : Math.floor((t - 3.5) * 2.6) % 2 === 0 ? 1 : 0;
        caret.style.opacity = on;
      }
      paint(0);

      /* left-to-right reveal through a feathered edge (feather 120px), blur clears behind the edge */
      const FEATHER = 120;
      function setReveal(el, p) {
        const w = el.offsetWidth;
        const x = -FEATHER / 2 + p * (w + FEATHER);
        const a = x - FEATHER / 2, b = x + FEATHER / 2;
        const m = "linear-gradient(90deg, #000 0px, #000 " + a.toFixed(1) + "px, transparent " + b.toFixed(1) + "px)";
        el.style.webkitMaskImage = m;
        el.style.maskImage = m;
        el.style.filter = "blur(" + (14 * Math.pow(1 - p, 2)).toFixed(2) + "px)";
      }
      const tl = gsap.timeline({ paused: true });
      function reveal(sel, start, dur) {
        const el = $(sel), o = { p: 0 };
        tl.to(o, { p: 1, duration: dur, ease: "power2.inOut", onUpdate: () => setReveal(el, o.p) }, start);
      }

      /* clock: gradient drift for the whole film */
      const clock = { t: 0 };
      tl.to(clock, { t: 11, duration: 11, ease: "none", onUpdate: () => paint(clock.t) }, 0);

      /* soft haze drifting */
      tl.to("#b1", { x: 160, y: 90, duration: 11, ease: "none" }, 0);
      tl.to("#b2", { x: -180, y: -70, duration: 11, ease: "none" }, 0);
      tl.to("#b3", { x: -120, y: 80, duration: 11, ease: "none" }, 0);

      /* ---------- beat 1: headline revealed through the moving mask ---------- */
      reveal("#l1", 0.3, 1.2);
      reveal("#l2", 0.6, 1.2);

      /* ---------- beat 2: headline shrinks up, search box, typed query ---------- */
      tl.to("#hl", { scale: 0.6, y: -284, duration: 0.7, ease: "power3.inOut" }, 2.9);
      tl.set("#sbox", { y: 34 }, 0);
      tl.to("#sbox", { opacity: 1, y: 0, duration: 0.55, ease: "expo.out" }, 3.5);
      const ty = { n: 0 };
      tl.to(ty, { n: Q.length, duration: 0.9, ease: "power1.inOut", onUpdate: () => { qEl.textContent = Q.slice(0, Math.round(ty.n)); } }, 4.0);
      tl.to("#go", { scale: 0.86, duration: 0.1, ease: "power2.in" }, 5.0);
      tl.to("#go", { scale: 1, duration: 0.35, ease: "back.out(3)" }, 5.1);

      /* answer: first line sweeps in with the same gradient reveal */
      reveal("#a1", 5.1, 1.2);
      tl.set("#a2", { y: 16 }, 0);
      tl.to("#a2", { opacity: 1, y: 0, duration: 0.6, ease: "power2.out" }, 5.8);
      tl.set(".chip", { y: 16 }, 0);
      tl.to(".chip", { opacity: 1, y: 0, duration: 0.5, ease: "power2.out", stagger: 0.12 }, 6.1);

      /* clear before the lockup */
      tl.to("#stage1", { opacity: 0, y: -24, duration: 0.35, ease: "power2.in" }, 7.8);

      /* ---------- lockup ---------- */
      tl.set("#mk", { scale: 0.6 }, 0);
      tl.set("#wm", { x: -24 }, 0);
      tl.set("#tag", { y: 14 }, 0);
      tl.to("#mk", { opacity: 1, scale: 1, duration: 0.55, ease: "back.out(1.6)" }, 8.15);
      tl.to("#wm", { opacity: 1, x: 0, duration: 0.55, ease: "expo.out" }, 8.2);
      tl.to("#tag", { opacity: 1, y: 0, duration: 0.5, ease: "power2.out" }, 8.3);

      tl.set({}, {}, 11);
      window.__timelines = window.__timelines || {};
      window.__timelines["main"] = tl;
    </script>
  </body>
</html>
```
