
The elastic button
Buttons, Hover, Text
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.
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>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
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 siteThe 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.
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.
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.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #ffb020 | The colour of the bar’s stripes and of the waiting light. |
GO | script.js | #3ddc84 | The colour of the go-ahead. |
AMOUNT | script.js | €3.40 | The toll amount. |
LIFT | script.js | 74 | How many degrees the bar lifts. |
PAYING | script.js | 1 | How many seconds the payment takes. |
HOLD | script.js | 2.2 | How many seconds the bar stays up before coming down. |
LOOP | script.js | true | Left alone, a pointer pays the toll. |
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.
The same button: 64 pixels tall, at most as wide as the screen, one whole tap target; long lines are cut with an ellipsis.
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.
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.
Tested on 18 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.