Skip to content
animorio
IT
All components

Course enrol button

Buttons, HoverGSAP, CSS onlyEasyCompressed weight: Demo 4.9 KBGSAP 28 KBFreeDownload the zip

The button to enroll in an online course, on white, in the simple style of product interface pieces: the black «Enroll» pill with a small arrow, and under it eight hairline segments, the weeks of the course. On tap a blue light runs along the weeks, from the first to the last, the first one keeps it and settles by a pixel; the arrow becomes a check and the label becomes «Enrolled».

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>
<!--
  "Course enrol 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>The course Enroll button with the weeks lighting up</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 button and one thin line under it: the weeks of the course; on enroll a light runs along them and the first week stays lit -->
    <div class="enroll" data-wrap>
      <button class="enroll__btn" type="button" data-btn aria-pressed="false">
        <span class="enroll__body" data-body>
          <span class="enroll__label" data-label aria-hidden="true">
            <span class="enroll__word" data-word="on">Enroll</span>
            <span class="enroll__word" data-word="off">Enrolled</span>
          </span>
          <span class="enroll__mark" data-mark aria-hidden="true">
            <svg class="enroll__arrow" data-arrow viewBox="0 0 20 20"><path d="M4.5 10h10.2M10.6 5.6 15 10l-4.4 4.4"/></svg>
            <svg class="enroll__check" data-check viewBox="0 0 20 20"><path d="M4.6 10.4 8.3 14l7.1-7.6"/></svg>
          </span>
        </span>
      </button>
      <div class="weeks" aria-hidden="true">
        <div class="weeks__row" data-row></div>
        <div class="weeks__note" data-note>
          <span class="weeks__text" data-text="on">8 weeks · Starts Nov 3</span>
          <span class="weeks__text" data-text="off">Week 1 · Nov 3</span>
        </div>
      </div>
      <span class="sr" aria-live="polite" data-live></span>
    </div>
  </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.

19 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 “Course enrol 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

On white, alone in the middle, there is a black pill with the word «Enroll» and a small arrow in a slightly lighter circle. Under it there are eight hairline grey segments, one per week of the course, and a grey line: «8 weeks · Starts Nov 3». On tap the pill gives a little and comes back on a spring; the arrow slips out to the right and a check draws itself in its place, going a hair too far and settling. «Enroll» rises away and «Enrolled» comes in, narrow at first and then wide on the width axis, and the pill stretches as much as it needs. Meanwhile a blue light runs along the weeks, from the first to the last: each segment lifts a pixel and lights up as it passes, then turns grey again. The first week keeps the light: it grows a hair thicker, lands a pixel high and settles. The line underneath rolls up into «Week 1 · Nov 3». On a second tap, more quietly, the first week lets the light go and the segments breathe from the last to the first; the arrow and «Enroll» come back. Hovering brings the pill a touch closer, the arrow steps forward and the weeks lift a pixel one after the other. Until someone touches it, the pill plays the gesture by itself.

How it works

The weeks in a row

The script creates the segments, one per week (WEEKS): spans 2 pixels tall and as wide as a letter, in a row with a small gap. They stay in the rail grey (--rail); they only take the accent colour while the light passes.

The running light

A single timeline: each segment in turn, 0.06 seconds apart, lifts a pixel and a half, thickens (scaleY 1.5) and takes the colour; right after, it turns grey and goes back to its place. The step gets shorter when there are many weeks, so the run always lasts about half a second.

The first one keeps it

The first segment does not go grey: it lands a pixel high and a hair thicker, then drops to rest with elastic.out once the light has reached the end. That settle is what says «it starts here».

Arrow, check and word

The arrow leaves to the right with power2.in; the check draws with strokeDashoffset down to minus 0.8, a hair past the end, and goes back to zero. The new word comes in narrow (wdth 75) and opens to 100 with back.out, and the pill takes its width measured in the final shape.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2f5bffThe colour of the light running along the weeks.
WEEKSscript.js8How many weeks the course lasts: one segment per week.
LABEL_ONscript.jsEnrollThe word on the button before enrolling.
LABEL_OFFscript.jsEnrolledThe word once enrolled.
NOTE_ONscript.js8 weeks · Starts Nov 3The line under the weeks before enrolling.
NOTE_OFFscript.jsWeek 1 · Nov 3The line under the weeks once enrolled.
SPRINGscript.js1How springy the press and the settle are: 0.4 calm, 2 very bouncy.
SPEEDscript.js1The speed of everything: 2 twice as fast, 0.5 half.
HOLDscript.js2.4How many seconds each state stays when the button plays by itself.
AUTOscript.jstrueThe button plays the gesture by itself until someone touches it.

Try them in the Playground

When to use it

For the enroll button of an online course, a school, a multi-session workshop or an academy: the weeks underneath say how long it lasts, and the light stopping on the first one says where it starts.

On phones

On the phone the pill, the segments and the text take their size from the shorter side of the screen (clamp with vmin); there is no hover, everything else is the same.

With reduced motion

Arrow, check, words and lines swap with a fade; the light does not run, the first week simply fades to the colour in place.

Pitfalls

  • The segments’ resting colour has to be read from the CSS (--rail) and handed to GSAP as a value: with an empty colour GSAP does not know where to go back to and the segment stays lit.
  • The first week has two tweens in the same timeline (lighting up with the run and staying high): the second goes after the light has reached the end, otherwise it settles while the others are still running and the gesture looks broken.
  • The new word’s width has to be measured in its final shape before it comes in narrow, and divided by the press scale: measured afterwards, the pill would stay short.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 4.9 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