Skip to content
animorio
IT
All components

Pay in 3 button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.2 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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.

17 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 “Pay in 3 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 sixty pixels tall: «Pay in 3», a light vertical rule and the total, $129.00. On tap the pill gives a little and comes back on a spring; «Pay in 3» narrows on the width axis and leaves to the side, while the total slides to the middle of the pill. There the pill splits: the two gaps open on a spring that goes a hair too far and comes back, the inner corners round off until three equal pills remain, and the total becomes the instalment, $43.00, flying from the middle into each one, with its date underneath: Today, then the first of the next two months. The first pill fills from left to right with lime green, like a payment going through, its text turns dark, «Today» rises away and a check that draws itself and «Paid» take its place; the pill jumps a little and settles. The other two, one after the other, turn white with a thin border: scheduled. On the next tap (or by itself after a pause) they turn black again, the instalments gather in the middle, the gaps close and the pill says «Pay in 3» again. Hovering shows two thin lines where the pill will split, like a promise. Until someone touches it, it plays the gesture by itself.

How it works

One pill that becomes three

Underneath 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.

No white line while joined

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 becomes the instalment

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 payment going through

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.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#c6f432The colour of the instalment being paid.
TOTALscript.js129The order total: the leftover cents go on the first instalment.
PARTSscript.js3How many instalments the total splits into, 2 to 4.
CURRENCYscript.js$The currency sign in front of the amounts.
GAPscript.js6The gap between the split pieces, in pixels.
PROCESSscript.js0.9How many seconds the first payment takes to go through.
SPRINGscript.js1How springy the split is: 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

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 phones

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.

With reduced motion

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.

Pitfalls

  • Three black pieces side by side left two thin white lines where they touch (edge antialiasing): while joined each piece reaches six tenths of a pixel into the next one.
  • The total's distance from the centre is measured with getBoundingClientRect while the button is bouncing after the press: it has to be divided by the scale of the moment, or the total stops a hair off centre.
  • The cents: 100 divided by 3 does not add up. The instalments are made in whole cents and the leftovers go on the first one, so the sum is always the total.

Libraries

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.

Testing

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