
The elastic button
Buttons, Hover, Text
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».
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>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
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 siteThe 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.
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 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».
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.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #2f5bff | The colour of the light running along the weeks. |
WEEKS | script.js | 8 | How many weeks the course lasts: one segment per week. |
LABEL_ON | script.js | Enroll | The word on the button before enrolling. |
LABEL_OFF | script.js | Enrolled | The word once enrolled. |
NOTE_ON | script.js | 8 weeks · Starts Nov 3 | The line under the weeks before enrolling. |
NOTE_OFF | script.js | Week 1 · Nov 3 | The line under the weeks once enrolled. |
SPRING | script.js | 1 | How springy the press and the settle are: 0.4 calm, 2 very bouncy. |
SPEED | script.js | 1 | The speed of everything: 2 twice as fast, 0.5 half. |
HOLD | script.js | 2.4 | How many seconds each state stays when the button plays by itself. |
AUTO | script.js | true | The button plays the gesture by itself until someone touches 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 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.
Arrow, check, words and lines swap with a fade; the light does not run, the first week simply fades to the colour in place.
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.
Tested on 31 October 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.