> ## 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.

# Matrix Decode

> Random scramble resolves left-to-right into the target text.

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="matrix-decode 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/matrix-decode.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/matrix-decode.png");document.body.appendChild(p)});<\/script></body></html>`} />

## Install

<InstallCommand command="npx hyperframes add matrix-decode" />

That writes one file: `compositions/components/matrix-decode.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`   | `HYPERFRAMES` | string                       | Word the scramble resolves into. One scrambling cell per character, up to 32. |
| `accent` | `green`       | `green`, `blue`, `violet`    | Colour family of the cells and their glow.                                    |
| `size`   | `64`          | 24px to 160px, step 4px      | Type size of the cells in pixels. Cell width follows it.                      |
| `glow`   | `standard`    | `none`, `standard`, `strong` | Strength of the halo behind the cells, from none to a heavy bloom.            |

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="matrix-decode"
  data-composition-src="compositions/components/matrix-decode.html"
  data-variable-values='{"text":"HYPERFRAMES","accent":"green","size":64,"glow":"standard"}'
></div>
```

## Source

<Accordion title={`matrix-decode.html`}>
  ```html theme={null}
  <!--
    Matrix Decode - remocn typography primitive for HyperFrames.

    Paste the markup, CSS and script into a composition. Drive the timeline
    integration from a paused GSAP timeline so renders remain deterministic.

    Variables. The script reads each one, falls back to the declared default on
    anything missing or invalid, and writes the result as a custom property the
    CSS consumes (or, for the target text, as the cells themselves). The timeline
    recipe below is untouched by them: it keeps staggering whatever cells are
    present.

      - text (text, default HYPERFRAMES): the word the scramble resolves into.
        One scrambling cell per character, up to 32. Also written to data-final,
        which a decode routine can read.
      - accent (green | blue | violet, default green): colour family of the cells
        and of their glow.
      - size (24 to 160 px, default 64): type size of the cells. The per-cell
        minimum width is a fixed fraction of it, so the row scales as a whole.
      - glow (none | standard | strong, default standard): halo strength behind
        the cells, from no shadow at all to a heavy bloom.

    On every default the result is identical to the original: eleven 64px green
    cells with an 18px halo.
  -->

  <div
    class="hf-remocn-matrix-decode"
    data-final="HYPERFRAMES"
    data-composition-variables='[
      { "id": "text", "type": "string", "role": "content", "label": "Target text", "description": "Word the scramble resolves into. One scrambling cell per character, up to 32.", "default": "HYPERFRAMES" },
      { "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Colour family of the cells and their glow.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] },
      { "id": "size", "type": "number", "role": "style", "label": "Size", "description": "Type size of the cells in pixels. Cell width follows it.", "default": 64, "min": 24, "max": 160, "step": 4, "unit": "px" },
      { "id": "glow", "type": "enum", "role": "style", "label": "Glow", "description": "Strength of the halo behind the cells, from none to a heavy bloom.", "default": "standard", "options": [{ "value": "none", "label": "None" }, { "value": "standard", "label": "Standard" }, { "value": "strong", "label": "Strong" }] }
    ]'
  >
    <span>0</span><span>0</span><span>0</span><span>0</span><span>0</span><span>0</span><span>0</span
    ><span>0</span><span>0</span><span>0</span><span>0</span>
  </div>

  <style>
    .hf-remocn-matrix-decode {
      color: #18181b;
      font-family: Inter, system-ui, sans-serif;
      font-weight: 900;
      letter-spacing: -0.04em;
    }
    .hf-remocn-matrix-decode {
      display: inline-flex;
      gap: 3px;
      font:
        900 64px/1 ui-monospace,
        SFMono-Regular,
        Menlo,
        monospace;
      font-size: var(--hf-matrix-size, 64px);
      color: var(--hf-matrix-color, #16a34a);
      text-shadow: 0 0 var(--hf-matrix-glow-radius, 18px)
        rgba(var(--hf-matrix-glow-rgb, 22, 163, 74), var(--hf-matrix-glow-alpha, 0.28));
    }
    .hf-remocn-matrix-decode span {
      display: inline-block;
      min-width: 0.64em;
      opacity: var(--hf-matrix-opacity, 1);
    }
  </style>

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

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

      // Anything missing or invalid returns to its declared default.
      var accents = {
        green: { color: "#16a34a", rgb: "22, 163, 74" },
        blue: { color: "#2563eb", rgb: "37, 99, 235" },
        violet: { color: "#7c3aed", rgb: "124, 58, 237" },
      };
      var glows = {
        none: { radius: "0px", alpha: "0" },
        standard: { radius: "18px", alpha: "0.28" },
        strong: { radius: "34px", alpha: "0.55" },
      };

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

      var text = typeof vars.text === "string" ? vars.text.trim().slice(0, 32) : "";
      if (!text) {
        text = "HYPERFRAMES";
      }

      var size =
        typeof vars.size === "number" || typeof vars.size === "string" ? Number(vars.size) : NaN;
      size = isFinite(size) && size > 0 ? Math.min(160, Math.max(24, size)) : 64;

      var accent = accents[pick(accents, vars.accent, "green")];
      var glow = glows[pick(glows, vars.glow, "standard")];

      var roots = document.querySelectorAll(".hf-remocn-matrix-decode");
      for (var i = 0; i < roots.length; i += 1) {
        roots[i].style.setProperty("--hf-matrix-size", size + "px");
        roots[i].style.setProperty("--hf-matrix-color", accent.color);
        roots[i].style.setProperty("--hf-matrix-glow-rgb", accent.rgb);
        roots[i].style.setProperty("--hf-matrix-glow-radius", glow.radius);
        roots[i].style.setProperty("--hf-matrix-glow-alpha", glow.alpha);
        roots[i].setAttribute("data-final", text);
        while (roots[i].firstChild) {
          roots[i].removeChild(roots[i].firstChild);
        }
        for (var j = 0; j < text.length; j += 1) {
          var cell = document.createElement("span");
          cell.textContent = text.charAt(j) === " " ? "\u00a0" : "0";
          roots[i].appendChild(cell);
        }
      }
    })();
  </script>

  <!--
    Timeline integration:
    tl.fromTo('.hf-remocn-matrix-decode span', { opacity: 0, y: 12 }, { opacity: 1, y: 0, duration: 0.18, stagger: 0.035, ease: 'power2.out' }, startTime);
  -->
  ```
</Accordion>

## Usage

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

Tagged `motion-primitive` `remocn-port` `typography`.

## 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

- [Matrix Decode](/catalog/components/caption-matrix-decode.md)
- [Caption styles](/prompting/captions-catalog.md)
- [Get unstuck](/help.md)
