Skip to content
animorio
IT
All components

Next episode button

Buttons, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 6.9 KBGSAP 28 KBFreeDownload the zip

The end of an episode of Low Tide, a made-up series, in a video player on black. While the credits roll, the screen shrinks into the corner and the «Up next» card arrives with the drawn thumbnail of Salt Lines: the «Next episode» pill fills with white from the left over eight seconds as a countdown, the seconds rolling and the label widening on the width axis. Resting the mouse on it pauses the countdown and swells the pill, a click grows the thumbnail until it fills the player, and «Watch credits» sends the pill away on a spring and brings the credits back full screen.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Next episode button" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Next episode button</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the end of an episode in a video player: the credits shrink into the corner, the Next episode pill fills as a
         countdown and plays the next one; hovering pauses it, Watch credits sends it away and brings the credits back -->
    <section class="player" data-player aria-label="Video player">
      <div class="screen" data-screen>
        <div class="screen__glow" aria-hidden="true"></div>
        <div class="credits" aria-hidden="true">
          <div class="credits__roll" data-roll>
            <p class="credits__show">Low Tide</p>
            <p class="credits__ep">The Harbour Light</p>
            <p><span>Directed by</span>Mara Quell</p>
            <p><span>Written by</span>Tomas Ide &amp; June Hart</p>
            <p><span>Director of photography</span>Ilse Varn</p>
            <p><span>Edited by</span>Rhea Moss</p>
            <p><span>Music by</span>Oskar Bly</p>
            <p><span>Production design</span>Noor Calder</p>
            <p><span>Sound</span>Elio Brandt</p>
            <p><span>Casting</span>Wren Okafor</p>
            <p class="credits__show">Low Tide</p>
            <p class="credits__ep">The Harbour Light</p>
            <p><span>Directed by</span>Mara Quell</p>
            <p><span>Written by</span>Tomas Ide &amp; June Hart</p>
            <p><span>Director of photography</span>Ilse Varn</p>
            <p><span>Edited by</span>Rhea Moss</p>
            <p><span>Music by</span>Oskar Bly</p>
            <p><span>Production design</span>Noor Calder</p>
            <p><span>Sound</span>Elio Brandt</p>
            <p><span>Casting</span>Wren Okafor</p>
          </div>
        </div>
      </div>

      <div class="scene" data-scene aria-hidden="true">
        <svg class="art" viewBox="0 0 160 90" preserveAspectRatio="xMidYMid slice"><use href="#art"/></svg>
        <div class="scene__title" data-scene-title>
          <span class="scene__kicker">Now playing</span>
          <span class="scene__name">Salt Lines</span>
        </div>
      </div>

      <div class="bar" aria-hidden="true"><span class="bar__done" data-bar></span></div>

      <div class="next" data-next>
        <div class="next__info">
          <span class="thumb" data-thumb aria-hidden="true">
            <svg class="art" viewBox="0 0 160 90" preserveAspectRatio="xMidYMid slice"><use href="#art"/></svg>
          </span>
          <span class="next__text">
            <span class="next__kicker">Up next · 44 min</span>
            <span class="next__title">Salt Lines</span>
          </span>
        </div>
        <div class="next__actions">
          <button class="pill" type="button" data-pill>
            <span class="pill__face" data-face>
              <span class="pill__fill" aria-hidden="true"></span>
              <span class="pill__label">
                <svg class="play" viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 3.2v9.6L12.6 8 4.5 3.2Z"/></svg>
                <span class="pill__word">Next episode</span>
                <span class="pill__sec"><span class="roll" data-sec><span class="roll__line">8</span></span></span>
              </span>
              <span class="pill__label pill__label--on" aria-hidden="true">
                <svg class="play" viewBox="0 0 16 16"><path d="M4.5 3.2v9.6L12.6 8 4.5 3.2Z"/></svg>
                <span class="pill__word">Next episode</span>
                <span class="pill__sec"><span class="roll" data-sec-on><span class="roll__line">8</span></span></span>
              </span>
            </span>
          </button>
          <button class="ghost" type="button" data-credits>Watch credits</button>
        </div>
      </div>
      <p class="sr" aria-live="polite" data-live></p>
    </section>

    <svg width="0" height="0" style="position:absolute" aria-hidden="true">
      <defs>
        <linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stop-color="#0b1424"/>
          <stop offset=".62" stop-color="#1d3150"/>
          <stop offset="1" stop-color="#5c7fb8"/>
        </linearGradient>
        <linearGradient id="sea" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stop-color="#16243d"/>
          <stop offset="1" stop-color="#060a12"/>
        </linearGradient>
        <radialGradient id="halo" cx=".5" cy=".5" r=".5">
          <stop offset="0" stop-color="#8fb8ff" stop-opacity=".55"/>
          <stop offset="1" stop-color="#8fb8ff" stop-opacity="0"/>
        </radialGradient>
        <g id="art">
          <rect width="160" height="90" fill="url(#sky)"/>
          <circle cx="112" cy="34" r="22" fill="url(#halo)"/>
          <circle cx="112" cy="34" r="7.5" fill="#dbe7ff"/>
          <rect y="56" width="160" height="34" fill="url(#sea)"/>
          <path d="M0 56h160" stroke="#8fb8ff" stroke-opacity=".55" stroke-width=".5"/>
          <path d="M104 60h16M100 65h24M96 71h32M92 78h40" stroke="#dbe7ff" stroke-opacity=".28" stroke-width=".7" stroke-linecap="round"/>
          <path d="M22 56V40l3-2 3 2v16" fill="#05080f"/>
          <path d="M23.5 41h3" stroke="#f2d38a" stroke-width="1.4"/>
        </g>
      </defs>
    </svg>
  </main>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

59 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Next episode button” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

A black video player with the end credits of «Low Tide», episode «The Harbour Light», slowly rolling: the series name, who directed, wrote and edited it, the music. After a moment the credits screen shrinks into the top left with rounded corners and the card arrives at the bottom right: the drawn thumbnail of the next episode (the sea at night, the moon and a lighthouse), «Up next · 44 min», the title «Salt Lines», the «Next episode» pill with its seconds and a «Watch credits» button. The pill fills with white over eight seconds, the light label giving way to a dark one under the fill, the seconds rolling down and the shadow growing. With the mouse on it the countdown waits and the pill swells; the click, Enter or the end of the countdown grow the thumbnail until it fills the player, with «Now playing · Salt Lines» and the timeline starting again. «Watch credits» or Esc squeeze the pill, send it away on a spring and bring the credits back full screen.

How it works

The countdown is a variable

GSAP takes a number from 0 to 1 over COUNT seconds with ease none and writes it to the CSS variable --p: the white fill is a scaleX(var(--p)), the dark label is a copy of the light one clipped with clip-path, the label widens with font-stretch and the shadow grows with the same number. The seconds are Math.ceil(COUNT × (1 − p)) and only roll when they change.

Waiting under the mouse

pointerenter pauses the countdown tween and swells the pill to HOVER_SCALE on a spring; pointerleave resumes it from where it was. Mouse only: on a phone the tap is already the click.

The thumbnail becoming the player

On click the thumbnail is measured inside the player with getBoundingClientRect and the next episode’s scene, the same drawing, starts from there: left, top, width and height grow to cover the whole player in GROW seconds with expo.inOut, and the corner radius goes from the thumbnail’s to the player’s.

Staying on the credits

Watch credits kills the countdown, squeezes the pill sideways, sends it off with back.in and brings the credits screen back to scale 1 on an elastic.out(1, SPRING) spring.

Values to change

NameFileDefaultWhat it changes
COUNTscript.js8Seconds of the countdown before the next episode plays by itself.
SHRINKscript.js0.56How small the credits get while the card is on screen.
CREDITS_SPEEDscript.js34Seconds the credits take to roll once.
GROWscript.js0.75Seconds the thumbnail takes to grow into the whole player.
HOVER_SCALEscript.js1.035How much the pill swells with the mouse on it.
SPRINGscript.js0.55How springy the credits are going back full screen (lower = more bounce).

Try them in the Playground

When to use it

At the end of a video on a streaming, course or video podcast site, in a playlist or a series of lessons: wherever the next piece starts by itself and the viewer must be able to stop it, skip ahead or put it off.

On phones

The player is taller and the card takes the full width under the shrunk credits; sizes are in em tied to both width and height, so everything fits the box. A tap is the click, without the mouse pause.

With reduced motion

No movement or springs: the credits dim instead of shrinking, the card fades in, the seconds change without rolling and the next episode fades in.

Pitfalls

  • The countdown must be paused, not killed, when the mouse arrives: recreating it would lose its place and the pill would start again from zero.
  • The growing scene must be measured at the click, not at load: the card slides in and the window may change size.
  • The credits are written twice: that way a yPercent −50 tween with repeat -1 loops without a jump.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.9 KB; the libraries: GSAP 28 KB.

Testing

Tested on 26 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All components