Skip to content
animorio
IT
All components

Split the bill card

Forms, HoverGSAP, CSS onlyMediumCompressed weight: Demo 9.1 KBGSAP 28 KBFreeDownload the zip

The card for splitting a dinner bill in a payments app between friends, on the palest grey: the total, a bar of coloured segments and four people with their share on rolling digits. Leave someone out with their checkbox or switch to Custom and drag one person’s share: all the others recalculate, the segments settle on a spring and the Request button shows what you’re owed, then turns green with «Sent to 2 friends».

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>
<!--
  "Split the bill card" 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 split the bill card with shares that recalculate</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" data-stage>
    <!-- split the bill in a payments app: the dinner total, four people with their shares on rolling wheels and a bar of
         coloured segments; leave someone out or switch to Custom and drag one share, every amount recalculates and the
         bar settles on a spring; Request sends the rest to your friends -->
    <section class="card" data-card aria-label="Split the bill">
      <header class="head">
        <span class="head__logo" aria-hidden="true">
          <svg viewBox="0 0 24 24"><path d="M12 4v16"></path><path d="M6.5 8.5a5.5 5.5 0 0 1 11 0"></path><path d="M17.5 15.5a5.5 5.5 0 0 1-11 0"></path></svg>
        </span>
        <span class="head__txt">
          <span class="head__app" data-app>Halvy</span>
          <span class="head__title">Split the bill</span>
        </span>
        <span class="head__place" data-place>Dinner at Brasa</span>
      </header>

      <div class="total">
        <span class="total__label">Total</span>
        <span class="total__amt money" data-total></span>
      </div>

      <div class="bar" data-bar aria-hidden="true"></div>

      <div class="modes" role="tablist" aria-label="How to split">
        <span class="modes__pill" data-modes-pill aria-hidden="true"></span>
        <button class="modes__btn is-on" type="button" role="tab" aria-selected="true" data-mode="equal">Equally</button>
        <button class="modes__btn" type="button" role="tab" aria-selected="false" data-mode="custom">Custom</button>
      </div>

      <ul class="people" data-people></ul>

      <button class="request" type="button" data-request>
        <span class="request__face" data-req-face>
          <span class="request__label">Request</span>
          <span class="request__amt money" data-req-amt></span>
        </span>
        <span class="request__busy" data-req-busy aria-hidden="true">
          <svg class="request__spin" viewBox="0 0 24 24" data-req-spin><circle cx="12" cy="12" r="8"></circle><path d="M12 4a8 8 0 0 1 8 8"></path></svg>
        </span>
        <span class="request__done" data-req-done aria-hidden="true">
          <svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" data-req-tick></path></svg>
          <span data-req-done-txt>Sent to 3 friends</span>
        </span>
      </button>
      <p class="sr" aria-live="polite" data-status></p>
    </section>

    <svg class="pointer" viewBox="0 0 24 24" aria-hidden="true" data-pointer><path d="M5 3l14 8.2-6.2 1.4 3.6 6.8-2.6 1.4-3.6-6.8L5 18.6z"></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.

27 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 “Split the bill card” 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 the palest grey sits the card of Halvy, an invented payments app, for splitting a dinner at Brasa: the total, $186.40, a thin bar divided into four coloured segments, the Equally and Custom switch and four people, you, Noor, Kai and Sana, each with an avatar in their colour, a line of detail and their share, $46.60. Below, the black «Request $139.80» button, what the others owe you. Unticking Sana dims her row, her segment closes and the others widen on a spring, while the shares roll to $62.14 and $62.13 and the request to $124.26. Switching to Custom the white pill slides across and under each friend’s name, in place of the line of detail, a slider appears with their colour and percentage: dragging Kai’s, his share grows, the others shrink, their knobs move by themselves and the bar follows your finger. Request squashes slightly, its label rises away, a circle spins and the button turns green with a tick drawing itself and «Sent to 2 friends». Then everything goes back. A drawn pointer does the whole round by itself; you can also really use it, with the checkboxes, the switch, the slider (arrow keys too) and the button.

How it works

Shares in cents

The bill is split in whole cents: with a custom share that comes off first, the rest is split equally among the others and the leftover cents go one by one to the first people in the list, so the sum always comes back to the total.

Digits on wheels

Each amount is made of windows always the same width, one per digit, each holding a column of ten numbers: to change a share every column moves by the yPercent of its new digit, from right to left, with a small overshoot.

The bar that settles

The segments are absolute inside the bar and their position and width are worked out in pixels from the shares, with two pixels between them; GSAP takes them there on a back.out spring, shorter and without bounce while dragging.

The slider that moves the others

The dragged slider fixes that person’s percentage; the others aren’t touched but are worked out again from their new share and glide into place by themselves, so you can see what a bigger share takes away.

Values to change

NameFileDefaultWhat it changes
APPscript.jsHalvyThe name of the invented payments app, at the top of the card.
PLACEscript.jsDinner at BrasaThe label of the expense being split.
TOTALscript.js186.4The total of the bill, in dollars.
ACCENTscript.js#4f46e5The colour of your share, the logo and the first person.
ROLLscript.js0.75The seconds the digits take to roll when the shares change.
SPRINGscript.js1.4How much the bar’s segments bounce as they settle.
CUSTOMscript.js45The percentage the autopilot gives Kai in the custom split.
PAUSEscript.js1.2The seconds the autopilot waits between one gesture and the next.

Try them in the Playground

When to use it

For a payments app between friends, an online bank, an app for group or travel expenses, a restaurant bill paid at the table: anywhere an amount is split between several people and it pays to show right away who owes what.

On phones

The card takes the full width minus the margins and its spacing tightens with vmin; the sliders are dragged with a finger (touch-action none on the track) and the checkboxes are big enough to tap.

With reduced motion

No rolling digits, springs or pointer: the bill is already split four ways, with the bar, the shares and the request in place; checkboxes, switch and sliders work and change the numbers without animation.

Pitfalls

  • Splitting dollars in floating point gets the last cent wrong and the shares don’t add up: everything is done in whole cents and the leftover cents are handed out one by one.
  • With natural-width digits the amounts would change size with every number and jiggle on the right; in Mona Sans tabular figures draw a slashed zero, so fixed-width windows are used instead of tabular-nums.
  • A slider under each row made the card taller and pushed it out of the phone frame: in Custom the slider takes the place of the line of detail under the name, in the same grid cell, so the card always keeps the same height.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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