> ## Documentation Index
> Fetch the complete documentation index at: https://hyperframes.heygen.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Text Stagger

> A transitions.dev-inspired text stagger primitive with enter, shimmer, and exit-ready words

export const InstallCommand = ({command}) => {
  const [copied, setCopied] = React.useState(false);
  const copy = async () => {
    try {
      if (navigator.clipboard && window.isSecureContext) {
        await navigator.clipboard.writeText(command);
      } else {
        const previous = document.activeElement;
        const scratch = document.createElement("textarea");
        scratch.value = command;
        scratch.setAttribute("readonly", "");
        scratch.style.position = "fixed";
        scratch.style.opacity = "0";
        document.body.appendChild(scratch);
        scratch.select();
        document.execCommand("copy");
        document.body.removeChild(scratch);
        previous?.focus?.();
      }
      setCopied(true);
      setTimeout(() => setCopied(false), 2000);
    } catch {}
  };
  return <div className="hf-install-command not-prose my-4 flex items-stretch overflow-hidden rounded-xl border border-zinc-200 bg-zinc-50 dark:border-zinc-800 dark:bg-zinc-900">
      <code className="flex-1 overflow-x-auto whitespace-nowrap border-r border-zinc-200 px-4 py-3 font-mono text-sm text-zinc-800 dark:border-zinc-800 dark:text-zinc-100">
        {command}
      </code>
      <button type="button" onClick={copy} data-copied={copied ? "true" : "false"} aria-label={`Copy ${command} to the clipboard`} className="hf-install-copy">
        <svg className="hf-install-copy-clipboard" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 18 18" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
          <path d="M14.25 5.25H7.25C6.14543 5.25 5.25 6.14543 5.25 7.25V14.25C5.25 15.3546 6.14543 16.25 7.25 16.25H14.25C15.3546 16.25 16.25 15.3546 16.25 14.25V7.25C16.25 6.14543 15.3546 5.25 14.25 5.25Z" />
          <path d="M2.80103 11.998L1.77203 5.07397C1.61003 3.98097 2.36403 2.96397 3.45603 2.80197L10.38 1.77297C11.313 1.63397 12.19 2.16297 12.528 3.00097" />
        </svg>
        <svg className="hf-install-copy-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 18 18" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
          <path d="M2.75 9.5L6.5 13.25L15.25 4.5" />
        </svg>
      </button>
      <span className="hf-install-copy-status" role="status" aria-live="polite">
        {copied ? "Copied" : ""}
      </span>
    </div>;
};

<iframe className="w-full aspect-video rounded-xl border-0 bg-zinc-100 dark:bg-zinc-800" title="text-stagger preview" loading="lazy" srcDoc={`<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;height:100%;overflow:hidden;background:transparent}hyperframes-player{display:block;width:100%;height:100%}</style><script src="https://cdn.jsdelivr.net/npm/@hyperframes/player@0.7/dist/hyperframes-player.global.js"><\/script></head><body><script>fetch("/public/catalog/components/text-stagger.json").then(function(r){return r.json()}).then(function(d){var p=document.createElement("hyperframes-player");p.setAttribute("srcdoc",d.html);p.setAttribute("controls","");p.setAttribute("autoplay","");p.setAttribute("loop","");p.setAttribute("muted","");p.setAttribute("poster","https://static.heygen.ai/hyperframes-oss/docs/images/catalog/components/text-stagger.png");document.body.appendChild(p)});<\/script></body></html>`} />

## Install

<InstallCommand command="npx hyperframes add text-stagger" />

That writes one file: `compositions/components/text-stagger.html`.

## Variables

Every one of these has a default, so the piece works untouched. Set the ones you
want to change on the element:

| Variable | Default                     | Accepts                   | What it does                                                                          |
| -------- | --------------------------- | ------------------------- | ------------------------------------------------------------------------------------- |
| `text`   | `Build motion systems fast` | string                    | Headline copy. Every whitespace-separated word becomes one staggered span.            |
| `size`   | `74`                        | 24px to 160px, step 1px   | Type size of every word in pixels, clamped to 24-160. Line height stays proportional. |
| `tone`   | `ink`                       | `ink`, `paper`            | Base word colour: ink for light frames, paper for dark ones.                          |
| `accent` | `blue`                      | `blue`, `green`, `violet` | Colour of the shimmer the second timeline step sweeps across the words.               |

Set them with `data-variable-values` on the element that mounts it. These are the
defaults, so this behaves exactly like the preview above until you change one:

```html wrap theme={null}
<div
  data-composition-id="text-stagger"
  data-composition-src="compositions/components/text-stagger.html"
  data-variable-values='{"text":"Build motion systems fast","size":74,"tone":"ink","accent":"blue"}'
></div>
```

## Source

<Accordion title={`text-stagger.html`}>
  ```html theme={null}
  <!--
    Text Stagger - transitions.dev-inspired primitive for HyperFrames.

    Paste the markup, CSS and script into a composition. Use the timeline
    integration note at the bottom as the starting point for deterministic GSAP
    animation.

    Variables. The script reads each one, falls back to the declared default on
    anything missing or unrecognised, and writes the result into the markup or
    into a custom property the CSS above consumes. The timeline recipe below is
    untouched by them: it keeps driving the same rise, blur and shimmer sweep.

      - text (string, default "Build motion systems fast"): the headline. It is
        split on whitespace and every word becomes its own span, so the word
        count decides how many steps the stagger has. Blank falls back to the
        default sentence.
      - size (number, default 74, clamped to 24-160 px): type size of every
        word. Line height stays proportional, so the block grows and shrinks as
        one. A missing or non-numeric value falls back to 74.
      - tone (ink | paper, default ink): base word colour. ink is near-black for
        light frames, paper near-white for dark ones. It paints both the resting
        words and the two dark stops of the shimmer gradient.
      - accent (blue | green | violet, default blue): the shimmer colour that the
        second timeline step sweeps across the words. It sits outside the visible
        band while the words rest, so it only shows once that sweep runs.

    On every default the result is identical to the original: four near-black
    74px words that rise through a blur and take one sky-blue shimmer pass.
  -->

  <div
    class="hf-transition-text-stagger"
    data-composition-variables='[
      {"id": "text", "type": "string", "role": "content", "label": "Text", "description": "Headline copy. Every whitespace-separated word becomes one staggered span.", "default": "Build motion systems fast"},
      {"id": "size", "type": "number", "role": "layout", "label": "Size", "description": "Type size of every word in pixels, clamped to 24-160. Line height stays proportional.", "default": 74, "min": 24, "max": 160, "step": 1, "unit": "px"},
      {"id": "tone", "type": "enum", "role": "style", "label": "Tone", "description": "Base word colour: ink for light frames, paper for dark ones.", "default": "ink", "options": [{"value": "ink", "label": "Ink"}, {"value": "paper", "label": "Paper"}]},
      {"id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Colour of the shimmer the second timeline step sweeps across the words.", "default": "blue", "options": [{"value": "blue", "label": "Blue"}, {"value": "green", "label": "Green"}, {"value": "violet", "label": "Violet"}]}
    ]'
  >
    <span>Build</span>
    <span>motion</span>
    <span>systems</span>
    <span>fast</span>
  </div>

  <style>
    .hf-transition-text-stagger {
      display: flex;
      flex-wrap: wrap;
      gap: 0.24em;
      color: var(--hf-stagger-ink, #111827);
      font:
        900 74px/0.95 Inter,
        system-ui,
        sans-serif;
      font-size: var(--hf-stagger-size, 74px);
      letter-spacing: -0.045em;
    }
    .hf-transition-text-stagger span {
      display: inline-block;
      background: linear-gradient(
        90deg,
        var(--hf-stagger-ink, #111827),
        var(--hf-stagger-ink, #111827),
        var(--hf-stagger-accent, #38bdf8),
        var(--hf-stagger-ink, #111827)
      );
      background-size: 240% 100%;
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      will-change: transform, opacity, filter, background-position;
    }
  </style>

  <script>
    (function () {
      "use strict";

      var vars =
        window.__hyperframes && window.__hyperframes.getVariables
          ? window.__hyperframes.getVariables()
          : {};

      // Unrecognised overrides return to their declared defaults.
      var DEFAULT_TEXT = "Build motion systems fast";
      var tones = { ink: "#111827", paper: "#f8fafc" };
      var accents = { blue: "#38bdf8", green: "#34d399", violet: "#a78bfa" };

      function pick(table, value, fallback) {
        return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;
      }

      var words = String(vars.text == null ? DEFAULT_TEXT : vars.text)
        .split(/\s+/)
        .filter(function (word) {
          return word.length > 0;
        });
      if (words.length === 0) words = DEFAULT_TEXT.split(" ");

      // Number(null) is 0, so null has to miss the numeric branch and clamp back
      // to the declared default instead of snapping to the minimum.
      var size = typeof vars.size === "number" ? vars.size : parseFloat(vars.size);
      if (!isFinite(size)) size = 74;
      size = Math.min(160, Math.max(24, size));

      var tone = tones[pick(tones, vars.tone, "ink")];
      var accent = accents[pick(accents, vars.accent, "blue")];

      var roots = document.querySelectorAll(".hf-transition-text-stagger");
      for (var i = 0; i < roots.length; i += 1) {
        var root = roots[i];
        root.style.setProperty("--hf-stagger-size", size + "px");
        root.style.setProperty("--hf-stagger-ink", tone);
        root.style.setProperty("--hf-stagger-accent", accent);
        // Rebuilt without whitespace between the spans: whitespace-only text
        // between flex items is not rendered, so this matches the markup above.
        root.textContent = "";
        for (var w = 0; w < words.length; w += 1) {
          var span = document.createElement("span");
          span.textContent = words[w];
          root.appendChild(span);
        }
      }
    })();
  </script>

  <!--
    Timeline integration:
    tl.fromTo('.hf-transition-text-stagger span', { opacity: 0, y: 48, filter: 'blur(14px)' }, { opacity: 1, y: 0, filter: 'blur(0px)', duration: 0.54, stagger: 0.09, ease: 'power3.out' }, 0.35);
    tl.to('.hf-transition-text-stagger span', { backgroundPosition: '100% 0%', duration: 0.72, stagger: 0.04, ease: 'power2.inOut' }, 1.05);
  -->
  ```
</Accordion>

## Usage

Open `compositions/components/text-stagger.html` and paste its contents into your composition. See the comment header in the file for detailed instructions.

Tagged `video-primitive` `transition-primitive` `transitions-dev-port` `text` `stagger`.

## Related topics

* [Browse the complete Catalog](/catalog)
* [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
* [Build a richer composition](/go-further)


## Related topics

- [Stagger Cascade](/catalog/components/stagger-cascade.md)
- [Stagger Lattice](/catalog/components/stagger-lattice.md)
- [Per Word Rise](/catalog/components/per-word-rise.md)
