Skip to content
animorio
IT
All components

Next lesson card

Cards, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.6 KBGSAP 28 KBFreeDownload the zip

The card of the next lesson of an online school, on white, in the simple style of product interface pieces: subject, topic, the teacher’s initials in a circle and the time. Underneath, a thin line holds the time left and runs down while the seconds roll in the corner; at zero the line opens back up in the accent colour and becomes, on a spring, the «Join now» button, and a ring draws around the initials.

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 lesson card" 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>The next lesson card with the time running down</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">
    <!-- one card, one gesture: the time left runs down a thin line, and at zero the line opens into «Join now» -->
    <article class="lesson" data-card aria-live="polite">
      <header class="lesson__top">
        <span class="lesson__state" aria-hidden="true">
          <span class="lesson__tag" data-tag="next">Next lesson</span>
          <span class="lesson__tag lesson__tag--live" data-tag="live">Live now</span>
        </span>
        <span class="lesson__left" data-left aria-hidden="true">
          <span class="lesson__in" data-in>in</span>
          <span class="lesson__clock" data-clock>0:06</span>
        </span>
      </header>
      <h2 class="lesson__subject" data-subject>Linear Algebra</h2>
      <p class="lesson__topic">Eigenvalues, part two</p>
      <div class="lesson__who">
        <span class="lesson__avatar" aria-hidden="true">
          <svg class="lesson__ring" viewBox="0 0 40 40"><circle data-ring cx="20" cy="20" r="18.5"/></svg>
          <span class="lesson__initials" data-initials>AK</span>
        </span>
        <span class="lesson__teacher">Ada Kern</span>
        <span class="lesson__hours">10:30 · 45 min</span>
      </div>
      <div class="lesson__slot">
        <span class="lesson__track" aria-hidden="true"><span class="lesson__time" data-time></span></span>
        <button class="lesson__join" type="button" data-join tabindex="-1" aria-hidden="true">
          <span class="lesson__joinword" data-joinword>Join now</span>
          <svg class="lesson__arrow" data-arrow viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.5M8.5 4l4 4-4 4"/></svg>
        </button>
      </div>
    </article>
  </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.

24 values to change

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 lesson card” 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

On white, alone in the middle, there is the card of the next lesson of an online school: at the top «Next lesson» in grey and, in the corner, «in 0:06»; then the subject, «Linear Algebra», the topic in grey, the teacher’s initials in a light circle with her name and the time. At the bottom a thin black line, on a grey hairline, holds the time left: it runs down towards the left, continuously, while each second of the clock rolls in from below with a one-pixel bounce. In the last three seconds the line and the digits turn blue, and the line takes a little breath with each second. At zero the clock rises away, the grey hairline fades and the blue comes back as a hair racing to the right; then the height springs open and the line becomes the «Join now» button, a pixel too far and settled. The word arrives narrow and opens up on the width axis, the arrow follows; «Next lesson» becomes «Live now» in blue, a thin ring draws around the initials and the card gives by a pixel. Hovering lifts the card a touch; over the button the word widens by a hair and the arrow moves forward, pressed it gives and springs back. Pressed, or after a couple of seconds, the button folds back into the line, which slides away and fills up again from the left for the next round. A tap on the card while it counts runs the time out at once.

How it works

The time in a line

An object { t } goes from 6 to 0 with a linear tween as long as the countdown; on every frame the line takes scaleX = t / 6 with its origin on the left, so it runs down continuously instead of in steps. The second on show is Math.ceil(t): the clock is rewritten only when it changes.

The seconds rolling in

The clock sits in a one-line column with overflow hidden: each new second comes in from yPercent 70 to 0 with back.out, which gives the one-pixel bounce. In the last seconds the colour and the line switch to the accent and the line breathes with scaleY from 1.9 to 1.

The line becoming a button

The button fills the whole row but is cut by a clip-path: inset(48% 100% 48% 0%) is a hair on the line, inset(48% 0% 48% 0%) the whole line, inset(0%) the open pill. First the width with power3.out, then the height with elastic.out: the ease goes a pixel too far and settles by itself, and it is all in percentages, so it survives a resize.

The word coming in narrow

«Join now» comes in with the wdth axis at 78 and the weight at 460 and lands at 100 and 580 with back.out; on hover it goes to 108. The tags at the top swap the same way, in the same grid cell, the old one leaving before the new one arrives.

The ring and the way back

The ring around the initials is a circle with strokeDasharray equal to its circumference, turned 90 degrees with svgOrigin: it draws from the top and, on the way back, slides off by going to minus the circumference. The pill folds back into the line, which leaves to the right (left inset at 100%), and the black line fills up again from the left.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2f62ffThe colour of the last seconds, of the ring and of the button.
COUNTDOWNscript.js6The seconds on the clock before the lesson starts.
LASTscript.js3The last seconds, when the line turns to the accent.
LABELscript.jsJoin nowThe word on the button.
SPRINGscript.js1How springy the button and the card are: 0.4 calm, 2 very bouncy.
SPEEDscript.js1The speed of everything: 2 twice as fast, 0.5 half.
HOLDscript.js2.6How many seconds the button stays before the card starts over by itself.
AUTOscript.jstrueThe card starts over by itself until someone touches it.

Try them in the Playground

When to use it

For the next lesson in a study app or an online school, and also for a webinar, a video appointment or a meeting in the calendar: the line tells how long is left without reading, and the button appears only when it is needed.

On phones

On the phone the card takes its width from the screen (the smaller of 320 pixels and 86vw) and its sizes from the shorter side; there is no hover, the button press is there, everything else is the same.

With reduced motion

The line shortens in steps, one second at a time, without sliding; at zero the button, the ring and the tag arrive with a fade, with no springs or movement.

Pitfalls

  • The button must not grow with scaleY: the word would be squashed. It is cut with a clip-path in percentages, which opens the whole pill without distorting it and stays right at any width, even if the window changes halfway.
  • Mona Sans with tabular-nums draws a slashed zero, so the digits stay proportional: the clock is right-aligned in a column with a minimum width, so «in» does not wobble when a 1 is narrower than a 0.
  • With round caps the ring, at the start of its drawing, is a speck above the initials: it fades in over the first quarter of a second, so a dot is never seen.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 31 October 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