Skip to content
animorio
IT
All components

Transit card top-up

Cards, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.6 KBGSAP 28 KBFreeDownload the zip

Topping up a public transport card: the teal card with its low balance and the rides left, three amounts to pick with a white tile sliding under the chosen one, and the Top up button. After a moment of payment, a ring spinning in the button, the balance on the card counts up to the new figure, the card lifts and a light crosses it, the rides roll and the tag goes from Low to Ready.

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>
<!--
  "Transit card top-up" 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>Transit card top-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">
    <!-- topping up a transit card: pick an amount, tap Top up, and the balance on the card rolls up
         while the rides left are worked out again -->
    <section class="tc" data-tc data-state="low" aria-label="Transit card">
      <div class="tc__card" data-card>
        <span class="tc__glare" data-glare aria-hidden="true"></span>
        <header class="tc__top">
          <b>Orbit</b>
          <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8.500 7.500a7 7 0 0 1 0 9M12 5a11 11 0 0 1 0 14M15.500 2.500a15 15 0 0 1 0 19"></path></svg>
        </header>
        <p class="tc__balance"><small>Balance</small><span><i>€</i><strong data-outbalance>3.40</strong></span></p>
        <footer class="tc__foot"><span class="tc__rides"><span data-outrides>2 rides left</span></span><span class="tc__flag" data-flag>Low</span></footer>
      </div>
      <div class="tc__amounts" role="radiogroup" aria-label="Amount to add" data-amounts>
        <span class="tc__thumb" data-thumb aria-hidden="true"></span>
        <button type="button" role="radio" aria-checked="false" data-amount="5">+ €5</button>
        <button type="button" role="radio" aria-checked="true" data-amount="10">+ €10</button>
        <button type="button" role="radio" aria-checked="false" data-amount="20">+ €20</button>
      </div>
      <button class="tc__btn" type="button" data-btn>
        <svg class="tc__spin" data-spin viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="7.500" pathLength="1"></circle></svg>
        <span class="tc__btntext"><span data-outbtn>Top up €10</span></span>
      </button>
    </section>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

21 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Transit card top-up” 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, a card in deep colours, teal to blue, with an arc of light at the bottom: at the top the name “Orbit” and the contactless waves, in the middle “Balance” and the large figure, at the bottom the rides left and an orange “Low” tag. Below, three amounts in a grey bar (plus 5, plus 10, plus 20 euro) with a white tile under the chosen one, and the dark “Top up €10” button. On opening the card arrives tilted and straightens. Pick an amount and the white tile slides under it on a spring while the button’s label rolls to the new figure. Tap Top up and the button tightens, a spinning ring appears and the label becomes “Paying”; a moment later the balance on the card counts quickly up to the total, the card tightens, turns slightly and springs back while a band of light crosses it, the rides roll to the new number and the tag becomes “Ready”, pale.

How it works

The amounts

Three buttons with role radio in a group: the keyboard arrows move from one to the next. The white tile is a third of the bar wide and moves with xPercent, a hundred per step: nothing needs measuring.

The payment

The button takes aria-busy, shows a ring spinning around its centre and ignores taps for LOAD seconds. On a real site the payment call goes here, and the rest starts when it answers.

The balance going up

The balance is a number animated by GSAP and written with two decimals on every frame. The rides are the balance divided by FARE, rounded down; under three rides the tag says Low.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0fa3a3The colour of the card.
STARTscript.js3.4The balance on opening, in euro.
FAREscript.js1.7What a ride costs: the rides left are worked out from it.
LOADscript.js0.9How many seconds the payment takes before the balance goes up.

Try them in the Playground

When to use it

In the app or site of a transport company, a bike sharing scheme, a car park; and wherever a credit is topped up in fixed steps: the canteen, the laundrette, a gym card, a game’s credit.

On phones

The piece is at most 288 pixels wide and about 280 tall; the card gets lower on low screens. The amounts are 42 pixels tall and a third of the bar wide, the button is as wide as the card and 46 tall.

With reduced motion

The white tile goes under the chosen amount at once, the ring does not spin and, once the payment is over, balance, rides and tag change in place, with no counting, springs or light. The demo’s pointer does not start.

Pitfalls

  • Money is added in rounded cents: 3.40 plus 20 in floating point can give 23.399999; here every sum is rounded to two decimals.
  • A low balance is not told by colour alone: the tag writes Low or Ready, and after the top-up the new balance and the rides land in an aria-live region.
  • The counting of the balance is for the eyes only: the real value changes at once, so a second tap starts from the right figure.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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