Skip to content
animorio
IT
All components

Pay toll button

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

A button for paying the toll at the gate: press it, a light crosses the pill while the payment goes through and the barrier trembles, then the striped bar lifts in its round tile, the amount becomes a tick and the lane light passes from amber to green. After a moment the bar drops back with its bounce.

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 toll 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>Pay toll button</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">
    <!-- a "pay toll" button: a light crosses the pill while the payment goes through, then the barrier
         lifts in its tile, the amount becomes a tick and the lane turns green; after a while the bar comes down -->
    <button class="tl" type="button" data-tl>
      <span class="tl__gate" aria-hidden="true">
        <svg viewBox="0 0 48 48">
          <path class="gate__ground" d="M9 37.500h30"></path>
          <rect class="gate__post" x="11" y="19" width="5.500" height="18.500" rx="1.800"></rect>
          <g transform="translate(13.750 23)"><g data-arm>
            <rect class="gate__arm" x="-1" y="-2.800" width="28" height="5.600" rx="2.800"></rect>
            <path class="gate__stripe" d="M6.500 -2.800h3.600l-2.200 5.600h-3.600ZM13.500 -2.800h3.600l-2.200 5.600h-3.600ZM20.500 -2.800h3.600l-2.200 5.600h-3.600Z"></path>
          </g></g>
          <circle class="gate__hinge" cx="13.750" cy="23" r="1.600"></circle>
        </svg>
      </span>
      <span class="tl__text">
        <span class="tl__line tl__line--a"><span data-a>Pay toll</span></span>
        <span class="tl__line tl__line--b"><span data-b>Riverside gate, lane 4</span></span>
      </span>
      <span class="tl__end" aria-hidden="true">
        <span class="tl__amount" data-amount></span>
        <svg class="tl__tick" viewBox="0 0 20 20"><path data-tick pathLength="1" d="M4.500 10.500 8.500 14.500 15.500 6"></path></svg>
      </span>
      <span class="tl__shine" aria-hidden="true"><i data-shine></i></span>
    </button>
    <p class="live" data-live aria-live="polite"></p>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></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.

13 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 toll 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, a dark pill: on the left a round tile with a toll barrier, white with amber stripes, closed, and an amber ring around it; in the middle “Pay toll” and below “Riverside gate, lane 4”; on the right the amount. Pressed, the pill gives and comes back on a spring, the lines roll to “Paying” and “Reading the plate”, the barrier gives two small shudders and a pale light crosses the pill from left to right. Once paid, the bar lifts, turning on its hinge with a small lunge, the ring and the pill’s shadow pass to green, the amount leaves upwards and a green tick is drawn in its place; the lines say “Paid, drive on” and “Receipt sent by email”. After a couple of seconds the bar drops, bounces once on its rest and everything is ready again.

How it works

The bar on its hinge

The bar is an SVG group drawn around zero inside a group moved onto the hinge: an animated number writes the angle into the transform attribute. It rises with back.out, drops with power2.in and bounces by six degrees.

Amber and green in a variable

The lane ring and the pill’s shadow are two color-mixes between amber and green driven by the same CSS variable from 0 to 1, which GSAP animates on payment and takes back to zero when the bar comes down.

One timeline, fixed times

Payment, lift and drop sit on one timeline with two labels, “paid” and “down”, placed at absolute times: the round lasts what PAYING and HOLD say, and a second press midway is ignored.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#ffb020The colour of the bar’s stripes and of the waiting light.
GOscript.js#3ddc84The colour of the go-ahead.
AMOUNTscript.js€3.40The toll amount.
LIFTscript.js74How many degrees the bar lifts.
PAYINGscript.js1How many seconds the payment takes.
HOLDscript.js2.2How many seconds the bar stays up before coming down.
LOOPscript.jstrueLeft alone, a pointer pays the toll.

Try them in the Playground

When to use it

In the app of a motorway, a barrier car park, a ferry or a restricted traffic zone, in the car’s own app; and wherever a payment opens a way through: a turnstile, a gate, a locker.

On phones

The same button: 64 pixels tall, at most as wide as the screen, one whole tap target; long lines are cut with an ellipsis.

With reduced motion

No shudders, lights or bounces: after the payment time the bar is already up and the green is on, then it is back down at once.

Pitfalls

  • In the demo the payment always succeeds after a second: a real one can fail, and needs the error state with the bar staying down.
  • While working the button has aria-busy and the outcome is announced in an aria-live line: the go-ahead is not told by green alone, there are the tick and the words.
  • Gate, lane and amount are made up; the plate reading is only a label.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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