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

# Headline Slam

> A heavyweight headline scales down into frame, lands with a deterministic three-frame shake, holds with subtle drift, and whips upward on exit.

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

## Install

<InstallCommand command="npx hyperframes add headline-slam" />

That writes one file: `compositions/components/headline-slam.html`.

## Paste it into your composition

Open `compositions/components/headline-slam.html` and copy what is inside into your own composition.

A component has no size or duration of its own. It takes both from the composition
you paste it into.

## 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`              | `Ship it today` | string                    | Text displayed as the headline.                                                      |
| `accent_word_index` | `1`             | number                    | Zero-based word index to color. Out of range leaves the headline unaccented.         |
| `accent`            | `green`         | `green`, `blue`, `violet` | Color applied to the selected word.                                                  |
| `shadow`            | `true`          | boolean                   | Drop shadow cast under the headline. On by default; set false for a flat matte look. |

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="headline-slam"
  data-composition-src="compositions/components/headline-slam.html"
  data-variable-values='{"text":"Ship it today","accent_word_index":1,"accent":"green","shadow":true}'
></div>
```

## Source

<Accordion title={`headline-slam.html`}>
  ```html theme={null}
  <!doctype html>
  <!--
    headline-slam: HyperFrames video primitive

    One headline scales down from 1.6 to rest with expo.out weight. Its landing
    drives a deterministic three-frame stage shake, followed by a quiet drift
    and a fast upward exit.

    Variables:
      text: headline copy
      accent_word_index: zero-based word index to color, out of range colors none
      accent: green, blue, or violet accent color
      shadow: drop shadow under the headline, on by default

    Envelope, fixed IN and OUT with elastic HOLD:
      IN_BASE  = 0.72s, headline slam and three-frame impact shake
      HOLD     = max(0, D - IN - OUT), one subtle drift cycle
      OUT_BASE = 0.46s, headline whips upward out of frame
      If D is shorter than IN_BASE + OUT_BASE, IN and OUT compress together.
      The timeline is never time-scaled.

    Mount contract: the runtime clones only this template. #root fills the host
    box, establishes the container query basis, and has no data-width or
    data-height. One paused timeline registers under the literal headline-slam
    key.
  -->
  <html
    lang="en"
    data-composition-id="headline-slam"
    data-composition-duration="3.5"
    data-composition-variables='[
      { "id": "text", "type": "string", "role": "content", "label": "Headline", "description": "Text displayed as the headline.", "default": "Ship it today" },
      { "id": "accent_word_index", "type": "number", "role": "content", "label": "Accent word index", "description": "Zero-based word index to color. Out of range leaves the headline unaccented.", "default": 1, "step": 1 },
      { "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Color applied to the selected word.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] },
      { "id": "shadow", "type": "boolean", "role": "style", "label": "Shadow", "description": "Drop shadow cast under the headline. On by default; set false for a flat matte look.", "default": true }
    ]'
  >
    <head>
      <meta charset="UTF-8" />
      <title>Headline Slam</title>
    </head>
    <body>
      <template>
        <div id="root" data-composition-id="headline-slam" data-duration="3.5" data-fps="30">
          <style>
            *,
            *::before,
            *::after {
              box-sizing: border-box;
            }

            #root {
              position: absolute;
              inset: 0;
              overflow: hidden;
              container-type: size;
              isolation: isolate;
              color: var(--fg, #f8fafc);
              font-family: var(--font-display, Inter, system-ui, sans-serif);
              pointer-events: none;
            }

            .hs-clip,
            .hs-stage {
              position: absolute;
              inset: 0;
              width: 100cqw;
              height: 100cqh;
            }

            .hs-clip {
              overflow: hidden;
            }

            .hs-stage {
              display: grid;
              place-items: center;
              will-change: transform;
            }

            .hs-headline {
              display: flex;
              align-items: center;
              justify-content: center;
              gap: 2cqw;
              width: 90cqw;
              min-height: 22cqh;
              color: var(--fg, #f8fafc);
              font-size: var(--hs-font-size, 10.5cqw);
              font-weight: 900;
              line-height: 0.88;
              letter-spacing: -0.5cqw;
              text-align: center;
              white-space: nowrap;
              transform-origin: 50% 50%;
              will-change: transform, opacity;
            }

            /* Shadow is on by default; the shadow variable opts out of it. */
            .hs-headline.hs-shadow {
              text-shadow: 0 1.2cqh 4.5cqh color-mix(in srgb, #000 52%, transparent);
            }

            .hs-word {
              display: inline-block;
            }

            .hs-word-accent {
              color: var(--hs-accent, #71f5a7);
            }
          </style>

          <div
            id="headline-slam-clip"
            class="hs-clip clip"
            data-start="0"
            data-duration="3.5"
            data-track-index="0"
          >
            <div class="hs-stage">
              <div class="hs-headline" role="heading" aria-level="1"></div>
            </div>
          </div>

          <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
          <script>
            (function () {
              "use strict";

              var root = document.getElementById("root");
              var stage = root.querySelector(".hs-stage");
              var headline = root.querySelector(".hs-headline");
              var vars =
                window.__hyperframes && window.__hyperframes.getVariables
                  ? window.__hyperframes.getVariables()
                  : {};

              var text = vars.text == null ? "Ship it today" : String(vars.text);
              var indexValue = Number(vars.accent_word_index);
              var accentWordIndex = Number.isFinite(indexValue) ? Math.trunc(indexValue) : 1;
              var accentColors = {
                green: "var(--brand, #71f5a7)",
                blue: "var(--accent, #61a8ff)",
                violet: "var(--accent-2, #b895ff)",
              };
              var accent = Object.prototype.hasOwnProperty.call(accentColors, vars.accent)
                ? vars.accent
                : "green";
              var shadow = !(vars.shadow === false || vars.shadow === "false");
              var words = text.trim() === "" ? [] : text.trim().split(/\s+/);

              root.style.setProperty("--hs-accent", accentColors[accent]);
              headline.classList.toggle("hs-shadow", shadow);
              headline.setAttribute("aria-label", text);

              words.forEach(function (word, index) {
                var span = document.createElement("span");
                span.className = index === accentWordIndex ? "hs-word hs-word-accent" : "hs-word";
                span.textContent = word;
                span.setAttribute("aria-hidden", "true");
                headline.appendChild(span);
              });

              // Deterministic fit from character count: DOM measurement is zero at
              // mount time (the template is not laid out yet), so it never fires.
              // 0.62 approximates the average glyph/em width of the bold face; the
              // 56cqw rest-state cap keeps the 1.6x overshoot peak inside 90cqw.
              var approxWidthCqw = text.length * 10.5 * 0.62;
              if (approxWidthCqw > 56) {
                var fitted = Math.max(3.5, 56 / (text.length * 0.62));
                root.style.setProperty("--hs-font-size", fitted.toFixed(2) + "cqw");
              }

              var IN_BASE = 0.72;
              var OUT_BASE = 0.46;
              var LAND_AT_BASE = 0.58;
              var SHAKE_FRAME_BASE = 1 / 30;
              var duration = Math.max(0.001, parseFloat(root.dataset.duration || "3.5"));
              var baseTotal = IN_BASE + OUT_BASE;
              var envelopeScale = duration < baseTotal ? duration / baseTotal : 1;
              var IN = IN_BASE * envelopeScale;
              var OUT = OUT_BASE * envelopeScale;
              var LAND_AT = LAND_AT_BASE * envelopeScale;
              var SHAKE_FRAME = SHAKE_FRAME_BASE * envelopeScale;
              var HOLD = Math.max(0, duration - IN - OUT);
              var HOLD_START = IN;
              var OUT_START = IN + HOLD;

              var tl = gsap.timeline({ paused: true });

              tl.fromTo(
                headline,
                { scale: 1.6, opacity: 0, y: 0 },
                { scale: 1, opacity: 1, y: 0, duration: LAND_AT, ease: "expo.out" },
                0,
              );

              tl.to(
                stage,
                { x: "0.55cqw", y: "-0.3cqh", duration: SHAKE_FRAME, ease: "power2.out" },
                LAND_AT,
              );
              tl.to(stage, {
                x: "-0.38cqw",
                y: "0.2cqh",
                duration: SHAKE_FRAME,
                ease: "power2.out",
              });
              tl.to(stage, { x: 0, y: 0, duration: SHAKE_FRAME, ease: "power2.out" });

              if (HOLD > 0) {
                tl.fromTo(
                  headline,
                  { y: 0 },
                  {
                    y: "-0.55cqh",
                    duration: HOLD / 2,
                    ease: "sine.inOut",
                    yoyo: true,
                    repeat: 1,
                    immediateRender: false,
                  },
                  HOLD_START,
                );
              }

              tl.to(headline, { y: "-120cqh", duration: OUT, ease: "power4.in" }, OUT_START);

              tl.seek(0);
              window.__timelines = window.__timelines || {};
              window.__timelines["headline-slam"] = tl;
            })();
          </script>
        </div>
      </template>
    </body>
  </html>
  ```
</Accordion>

Tagged `motion-primitive` `typography` `headline` `slam` `impact` `exit`.

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

- [Char Slam Explode](/catalog/components/char-slam-explode.md)
- [Kinetic Slam](/catalog/components/caption-kinetic-slam.md)
- [Music videos and slideshows](/prompting/music-and-slideshows.md)
