Skip to content
motionprompts motionprompts

Hold To Enter Gate

GSAP animation component · Published 2026-11-21 · by vanguardia.dev

Open live demo ↗ Raw prompt (.md)

What it does

Full-screen black veil with a large headline and an "Enter" pill: holding it (pointer, or Enter/Space) fills a track beside it, releasing early drains it back, and on completion the headline leaves character by character through line masks and the veil fades to reveal the page underneath. A Replay button closes the veil again.

How it's built

Categoryinteractive
Techgsap
GSAP pluginsSplitText
Complexitypage
Performance costlight
Mobile-safeyes

hold-to-enter press-and-hold gate preloader splittext veil intro progress

Rebuild it with AI

To reproduce this animation in your own project, copy the prompt below into Claude Code, Cursor or any AI coding agent. The prompt is validated, it describes the exact structure, timing and easing, so the agent rebuilds the effect faithfully and you can then adapt colors, copy and layout to your design.

The full prompt

Hold To Enter Gate: Press-and-Hold Pill That Fills a Track and Splits the Headline Away

Goal

Build a full-viewport black veil sitting over a white page. On the veil: a large three-line headline "Open the next way / to grow what / is yours" and, under it, a white "Enter" pill with a thin track attached to its right edge and a small "Press and hold" hint. While the user holds the pill down (pointer, or Enter / Space with the pill focused) the track fills left to right in 1.4 s at a constant rate. Releasing early drains it back to empty. When it completes, the headline leaves character by character upwards through line masks (SplitText), the row fades, and the veil fades out to show the page underneath: one centred headline "You are in." and a Replay button that closes the veil again. GSAP only, no scroll involved.

Tech

Vanilla HTML/CSS/JS with ES module imports. gsap (npm) and gsap/SplitText. Font: Schibsted Grotesk (500).

Layout / HTML

<div class="hg">
  <main class="hg-content">
    <h2 class="hg-inside">You are in.</h2>
    <button class="hg-reset" type="button" data-hg-reset>Replay</button>
  </main>
  <div class="hg-veil" data-hg-veil>
    <h1 class="hg-title" data-hg-title>Open the next way<br />to grow what<br />is yours</h1>
    <div class="hg-row" data-hg-row>
      <button class="hg-btn" type="button" data-hg-btn aria-label="Press and hold to enter"><span>Enter</span></button>
      <span class="hg-track" aria-hidden="true"><i data-hg-fill></i></span>
      <p class="hg-hint">Press and hold</p>
    </div>
  </div>
</div>

Styling

:root: --hg-bg:#0a0a0a, --hg-ink:#fff, --hg-paper:#fff, --hg-paper-ink:#0a0a0a, --hg-accent:#fff (track fill and focus ring), --hg-size:clamp(2.5rem,7.4vw,7.5rem).

  • .hg: position:relative; height:100svh; min-height:520px; overflow:hidden.
  • .hg-content: absolute, inset:0, flex column centred, gap:2rem, white background, black text. .hg-inside at --hg-size, weight 500, letter-spacing:-.04em. .hg-reset: outlined pill (1px solid currentColor, border-radius:999px, padding:.7rem 1.3rem).
  • .hg-veil: absolute, inset:0; z-index:2, flex column centred vertically, gap:clamp(2rem,6vh,4rem), padding:0 clamp(1.25rem,8vw,9rem), background --hg-bg.
  • .hg-title: --hg-size, weight 500, line-height:.98, letter-spacing:-.045em, margin 0.
  • .hg-btn: height:56px; padding:0 2.2rem; border-radius:999px, white background, black text, touch-action:none; user-select:none (so a long press on touch does not scroll or select). Focus ring outline:2px solid var(--hg-accent); outline-offset:4px.
  • .hg-track: width:clamp(140px,22vw,280px); height:10px; margin-left:-6px (tucked under the pill), border-radius:0 10px 10px 0, background:rgba(255,255,255,.16), overflow:hidden. Its <i> is the fill: full size, --hg-accent, transform-origin:left center; transform:scaleX(0).
  • .hg-hint: .85rem, 55 % white, hidden under 560px.

GSAP effect (be exact)

Build in mount(config) → destroy().

const DEFAULTS = { hold: 1.4, release: 0.4, exit: 0.6, stagger: 0.006 };
  • At mount: SplitText.create(title, { type: "chars,lines", mask: "lines" }).
  • start(e) (on pointerdown of the pill, and keydown Enter/Space without e.repeat): preventDefault(), kill the current fill tween, then gsap.to(fill, { scaleX: 1, duration: hold, ease: "none", onComplete: enter }).
  • stop() (on pointerup on window, pointerleave / pointercancel of the pill, keyup Enter/Space): if not entered, kill the fill tween and gsap.to(fill, { scaleX: 0, duration: release, ease: "power2.out" }). The drain starts from wherever the fill was.
  • Prevent the pill's click and contextmenu defaults (a keyboard Enter would otherwise also fire a click).
  • enter() once: timeline
  • split.chars → yPercent:-110, duration: exit, stagger, ease:"power3.in" at 0;
  • .hg-row → opacity:0, duration:.4 at 0;
  • veil → autoAlpha:0, duration:.5, ease:"power2.out" at ">-0.15";
  • then move focus to Replay.
  • Replay: kill timelines, entered = false, set chars yPercent:0, row opacity:1, fill scaleX:0, veil autoAlpha:1, focus the pill.
  • prefers-reduced-motion: reduce: the hold still fills (it is user driven), but on completion the veil just fades in .2 s without the character exit.

destroy(): remove all listeners, kill tweens, clearProps:"all" on fill, row and veil, split.revert().

Assets / images

None.

Behavior notes

  • The fill is a linear tween, not a CSS transition, so killing it mid-way and reversing from the current value is exact.
  • window pointerup catches a release that happens off the pill; pointerleave drains it when the pointer slides away.
  • The veil is a sibling over the content, not a separate page: replace .hg-content with your real page.
  • Only the prefixed variables are global.

Using this outside its demo page

This component is written as a complete page: that is how the demo is meant to look. If you are dropping it into an existing project, or combining it with other components, these are the things it declares at document level and that you need to move or reconcile first.

  • Palette on :root: --hg-bg, --hg-ink, --hg-paper, --hg-paper-ink, --hg-accent, --hg-size. Generic names like --ink, --paper or --muted are defined by many components in this catalogue with different values, and they will also collide with whatever your own project defines. Move them onto the component's wrapper (.my-section { --ink: … }) or keep the prefix.
  • **Rules on *, *::before, *::after, html, body**: the demo owns the whole document, so these set the box model and resets. Dropped into an existing project they restyle the entire page, not just this section. Re-target them at the component's wrapper before using it.

New components in your inbox

One email a week, only when new components ship, each with its live demo and prompt.