Skip to content
animorio
IT
All components

Complete lesson button

Buttons, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 5.2 KBGSAP 28 KBFreeDownload the zip

The button at the end of a lesson in an online course: a light pill with the course ring, the lesson’s title and the percentage done. Pressed, a blue tint leaves the ring and floods the pill, the ring advances by one lesson while the percentage counts, a green tick draws itself in the centre and the label says which lesson comes next.

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>
<!--
  "Complete lesson 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>Complete lesson button with the course ring that advances</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 button at the end of a lesson in an online course: pressed, a tint leaves the ring and floods the pill,
         the course ring advances by one lesson while the percentage counts, a tick draws itself and the label
         says which lesson comes next -->
    <button class="crs" type="button" data-crs>
      <span class="crs__body" aria-hidden="true"><span class="crs__wash" data-wash></span><span class="crs__light"></span></span>
      <span class="crs__edge" aria-hidden="true"></span>

      <span class="seat" data-seat aria-hidden="true">
        <svg viewBox="0 0 24 24">
          <circle class="seat__track" cx="12" cy="12" r="10.2"></circle>
          <circle class="seat__ring" data-ring cx="12" cy="12" r="10.2" pathLength="1" transform="rotate(-90 12 12)"></circle>
          <path class="seat__play" data-play d="M10 8.300 15.600 12 10 15.700Z"></path>
          <path class="seat__tick" data-tick pathLength="1" d="M8.2 12.4 10.9 15 15.9 9.4"></path>
        </svg>
      </span>

      <span class="label">
        <span class="label__main"><span data-word>Complete lesson</span></span>
        <span class="label__sub"><span data-sub>Colour and contrast</span></span>
      </span>
      <span class="tag" aria-hidden="true"><span data-pct>58%</span></span>
    </button>
    <p class="sr" data-live aria-live="polite"></p>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></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.

16 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 “Complete lesson 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

In the centre, on black, a light pill 60 pixels tall whose edge catches the light: on the left, in a white seat, a blue ring a little more than half full with a small triangle in the centre, then “Complete lesson” with the lesson’s title below (“Colour and contrast”) and on the right a tag with “58%”. Pressed, a blue tint leaves the ring and spreads over the whole pill, the triangle closes, the ring advances to 67% slowing on arrival and the tag counts with it. Then everything turns green: a tick draws itself in the ring, the seat bounces, the label says “Lesson complete” and below “Next: Type on a grid”. After a couple of seconds it goes back, with the ring rewinding.

How it works

One number only

The course progress is one number between 0 and 1 (lessons done over LESSONS). The same function shortens the ring’s stroke-dashoffset and rewrites the percentage: on press, the number goes to the next lesson with power3.out, no spring.

The tint from the ring

Inside the pill there is a coloured layer clipped with clip-path: circle() centred on the ring: the radius goes from 0 to 360 pixels, so the colour seems to come out of the ring.

The close

The triangle scales to zero, the tick draws itself with stroke-dashoffset, seat and pill make a small elastic bounce and a class takes ring and tint to green; the two lines roll to the new text.

Values to change

NameFileDefaultWhat it changes
LESSONSscript.js12How many lessons the course has.
DONE_SO_FARscript.js7How many are already done before this one.
LESSONscript.jsColour and contrastThe lesson being completed (invented).
NEXTscript.jsType on a gridThe lesson that comes next (invented).
ACCENTscript.js#2f6bffThe colour of the course ring.
OKscript.js#12a868The colour once the lesson is completed.
HOLDscript.js2.6On its own: how many seconds the summary stays before going back.
LOOPscript.jstrueLeft alone, a pointer tries it by itself.

Try them in the Playground

When to use it

For an online school, a course platform, an app for learning a language or an instrument: the button at the end of the lesson, which shows the course advancing. It also suits the steps of a sign-up, a guide’s chapters, the stages of a training plan.

On phones

The same button: the pill takes at most the screen width minus the margins; it is pressed with a finger and there is no light under the pointer.

With reduced motion

No spreading tint or bounces: the colour fades in, the ring and the percentage go to the new value at once, labels and tick change in place.

Pitfalls

  • The percentage uses no spring: a 67% that reaches 69 and comes back looks like a mistake.
  • The tag shows the percentage, not “8 of 12”: ordinal numbering as graphics is not used, and the lesson is named by its title.
  • With an empty course the ring must be hidden with opacity: a round-capped stroke of zero length leaves a dot at the top.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 15 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