
The elastic button
Buttons, Hover, Text
One button, one gesture, in the simple style of product interface pieces: the black «Pay in 3» pill at an online shop's checkout; on tap the total slides to the middle and the pill splits on a spring into three equal pills, with the instalment flying from the middle into each one and its date underneath. The first fills with the accent colour like a payment going through and says «Paid» with a check, the others turn white, scheduled. Another tap joins them back together.
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>
<!--
"Pay in 3 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 Pay in 3 button with the total that splits</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, one gesture: the total splits into equal instalments, the first one is paid -->
<button class="pay" type="button" data-pay aria-label="Pay in 3, total $129.00">
<span class="pay__body" data-body>
<span class="pay__whole" data-whole aria-hidden="true"></span>
<span class="pay__segs" data-segs aria-hidden="true"></span>
<span class="pay__seams" data-seams aria-hidden="true"></span>
<span class="pay__rest" data-rest aria-hidden="true">
<span class="pay__label" data-label>Pay in 3</span>
<span class="pay__rule" data-rule></span>
<span class="pay__total" data-total>$129.00</span>
</span>
</span>
</button>
<p class="pay__status" data-status role="status" aria-live="polite"></p>
</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.
17 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 “Pay in 3 button” from Animorio and fit it into my siteUnderneath sits the whole pill; on top, invisible, three pieces laid out in pixels. At the moment of the split the whole pill disappears and the pieces show, joined and identical to it: nobody sees the swap. Then a single { gap, inner } object goes with back.out from zero to the gap and to round inner corners, and on every frame the layout function recomputes each piece's left, width and border-radius.
Three black rectangles side by side on white leave a light line where they touch, because of antialiasing. While the gap is under half a pixel each piece reaches six tenths into the next one, and the line is gone.
The total slides to the middle by measuring the distance between its centre and the pill's (divided by the button's scale, which is bouncing at that moment). Then it fades and each instalment starts at an x equal to the distance between the pill's centre and its piece's centre and lands at zero with back.out: they all seem to come out of the same number.
The accent fill is a layer inside the first piece with scaleX from 0 to 1 and its origin on the left; halfway the text turns dark, at the end «Today» leaves upwards and the check (strokeDashoffset) and «Paid» come in. The other pieces go from black to white with a border, which is a CSS variable tweened by GSAP inside the shadow.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #c6f432 | The colour of the instalment being paid. |
TOTAL | script.js | 129 | The order total: the leftover cents go on the first instalment. |
PARTS | script.js | 3 | How many instalments the total splits into, 2 to 4. |
CURRENCY | script.js | $ | The currency sign in front of the amounts. |
GAP | script.js | 6 | The gap between the split pieces, in pixels. |
PROCESS | script.js | 0.9 | How many seconds the first payment takes to go through. |
SPRING | script.js | 1 | How springy the split is: 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. |
At the checkout of an online shop that offers instalments, on the page of an expensive product or in the summary of a payments app: the pill that splits says by itself how much is paid today and how much later.
On the phone the pill is as wide as the screen minus the margins (320 pixels at most) and the words take their size from the shorter side; there are no hover lines, everything else is the same.
Nothing moves: the whole pill fades into the three pieces already split, the first instalment's colour fades in, «Today» gives way to «Paid» in place and the others fade to white.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.2 KB; the libraries: GSAP 28 KB.
Tested on 1 November 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.