
The layered button
Buttons, Hover, Physics
The donation form of Springline, a made-up charity bringing clean water, in a white card from a premium shot. At the top the One-time / Monthly switch with its sliding pill, under it four amount pills, 10, 25, 50 and 100 dollars, and Other, which widens and opens the field to type the figure; a blue indicator slides from one amount to the next on two springs and stretches the way it runs. Below, the impact line: the litres of safe water and the days for a family roll like counters, beside a drawn water can that fills in proportion with the surface wave settling. The Donate $25 monthly button rolls its digits and widens on a spring; pressed, it swells and becomes Thank you with the check drawing itself.
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>
<!--
"Donation amount picker" 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>Donation amount picker</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>
<!-- the donation picker of Springline, an invented clean water charity: one-time or monthly, four amounts and
Other, the impact line with rolling figures and a water can that fills in proportion -->
<form class="gift" aria-labelledby="g-title" data-card novalidate>
<header class="gift__head">
<p class="gift__brand">
<svg class="gift__drop" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1.6c2.5 3 4.4 5.4 4.4 7.8A4.4 4.4 0 0 1 8 13.8a4.4 4.4 0 0 1-4.4-4.4C3.6 7 5.5 4.6 8 1.6Z"/><path class="gift__drop-shine" d="M6 9.6a2 2 0 0 0 1.6 1.9"/></svg>
<span>Springline</span>
</p>
<h2 class="gift__title" id="g-title">Give clean water</h2>
</header>
<div class="freq" role="radiogroup" aria-label="How often" data-freq>
<span class="freq__thumb" aria-hidden="true" data-freq-thumb></span>
<button class="freq__opt" type="button" role="radio" aria-checked="true" data-freq-opt="once">One-time</button>
<button class="freq__opt" type="button" role="radio" aria-checked="false" tabindex="-1" data-freq-opt="monthly">Monthly</button>
</div>
<div class="amounts" role="radiogroup" aria-label="Amount" data-amounts>
<span class="amounts__ind" aria-hidden="true" data-ind><i></i></span>
<button class="amt" type="button" role="radio" aria-checked="false" tabindex="-1" data-amt="10"><span class="amt__in">$10</span></button>
<button class="amt" type="button" role="radio" aria-checked="true" data-amt="25"><span class="amt__in">$25</span></button>
<button class="amt" type="button" role="radio" aria-checked="false" tabindex="-1" data-amt="50"><span class="amt__in">$50</span></button>
<button class="amt" type="button" role="radio" aria-checked="false" tabindex="-1" data-amt="100"><span class="amt__in">$100</span></button>
<span class="amt-slot" data-other-slot>
<button class="amt amt--other" type="button" role="radio" aria-checked="false" tabindex="-1" data-amt="other"><span class="amt__in amt__word" data-other-word>Other</span></button>
<label class="amt__field" data-other-field>
<span class="amt__cur" aria-hidden="true">$</span>
<input class="amt__input" type="text" inputmode="numeric" autocomplete="off" maxlength="4" aria-label="Other amount in dollars" value="" placeholder="40" tabindex="-1" data-other-input>
</label>
</span>
</div>
<div class="impact" data-impact>
<div class="can" aria-hidden="true">
<svg viewBox="0 0 100 120" data-can>
<defs>
<clipPath id="can-in"><path d="M25 33h40q5 0 8.6 3.6l9.6 9.6q3.3 3.3 3.3 8V99q0 10-10 10H24q-10 0-10-10V44q0-11 11-11Z"/></clipPath>
<linearGradient id="water" x1="0" y1="0" x2="0" y2="1">
<stop class="water-top" offset="0"/>
<stop class="water-deep" offset="1"/>
</linearGradient>
<linearGradient id="can-body" x1="0" y1="0" x2="1" y2="0">
<stop offset="0" stop-color="#f4f8fc"/>
<stop offset="0.55" stop-color="#ffffff"/>
<stop offset="1" stop-color="#eaf1f8"/>
</linearGradient>
<linearGradient id="can-sheen" x1="0" y1="0" x2="1" y2="0">
<stop offset="0" stop-color="#fff" stop-opacity="0"/>
<stop offset="0.5" stop-color="#fff" stop-opacity="0.55"/>
<stop offset="1" stop-color="#fff" stop-opacity="0"/>
</linearGradient>
</defs>
<!-- the handle and the cap -->
<path class="can__handle" d="M22 31V20q0-7 7-7h22q7 0 7 7v11"/>
<path class="can__handle can__handle--in" d="M30 31v-8q0-3 3-3h14q3 0 3 3v8"/>
<g class="can__cap" data-cap><rect x="77.5" y="30" width="13" height="10" rx="2.6" transform="rotate(45 84 35)"/></g>
<path class="can__body" d="M24 30h42q6 0 10.4 4.4l10.2 10.2q3.9 3.9 3.9 9.4V100q0 12-12 12H23q-12 0-12-12V43q0-13 13-13Z"/>
<g clip-path="url(#can-in)">
<path class="can__water" d="" fill="url(#water)" data-water/>
<path class="can__crest" d="" data-crest/>
<g data-bubbles>
<circle class="can__bubble" cx="34" cy="104" r="1.6"/>
<circle class="can__bubble" cx="58" cy="104" r="1.1"/>
<circle class="can__bubble" cx="46" cy="104" r="1.3"/>
</g>
<rect class="can__sheen" x="20" y="30" width="9" height="82" fill="url(#can-sheen)"/>
</g>
<!-- the litre marks on the side -->
<g class="can__marks" data-marks>
<path d="M76 58h5"/><path d="M76 71h4"/><path d="M76 84h5"/><path d="M76 97h4"/>
</g>
<path class="can__rim" d="M24 30h42q6 0 10.4 4.4l10.2 10.2q3.9 3.9 3.9 9.4V100q0 12-12 12H23q-12 0-12-12V43q0-13 13-13Z"/>
</svg>
</div>
<div class="impact__text">
<p class="impact__label">Your impact</p>
<p class="impact__big"><span class="roll" data-roll-litres></span><span class="impact__unit">litres</span><span class="impact__month" data-month-word>a month</span></p>
<p class="impact__line">of safe water, <span data-roll-days class="roll roll--small"></span> days<br>for a family of five</p>
</div>
</div>
<button class="give" type="submit" data-give data-autoclic>
<span class="give__face" data-give-face>
<span class="give__glow" aria-hidden="true" data-give-glow></span>
<span class="give__sheen" aria-hidden="true" data-give-sheen></span>
<span class="give__label" data-give-label>
<span>Donate</span>
<span class="give__sum">$<span class="roll" data-roll-sum></span></span>
<span class="give__month" data-give-month>monthly</span>
</span>
<span class="give__label give__label--done" data-give-done aria-hidden="true">
<svg class="give__check" viewBox="0 0 16 16"><path d="M3.4 8.4 6.6 11.4 12.6 4.6" data-check/></svg>
<span>Thank you</span>
</span>
</span>
</button>
<span class="measure" aria-hidden="true" data-measure></span>
<p class="sr" aria-live="polite" data-live></p>
</form>
</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.
45 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 “Donation amount picker” from Animorio and fit it into my siteThe blue ring has no single position but two edges, left and right, each with its own damped spring in GSAP’s ticker, the time step capped at 1/30 of a second. The edge in front, in the direction of travel, has 1.45 times the base stiffness, the one behind 0.62: the ring stretches as it runs and closes up as it arrives. The targets are read again every frame from offsetLeft and offsetWidth, so the ring also follows the Other pill while it widens.
Other lives in a flexible slot: GSAP takes its flexGrow from 1.25 to 2.3 with a back.out and the other pills narrow by themselves. The word fades with a touch of blur and the field appears on top with an elastic scale; the typed text is cleaned on every key (digits only, no leading zeros, at most 2000).
The surface is an SVG path redrawn every frame inside a clipPath shaped like the can: the level follows the amount on a spring, two sines with different phases make the wave that dies away exponentially, and a tilt on another damped spring makes it sway. A white line follows the crest, and the litre marks change colour when the level passes them.
Litres, days and the sum are columns from 0 to 9 in boxes 1ch wide, with the thousands comma opening by itself, and they roll with a back.out. The button’s width is worked out from its parts, measured once in a hidden twin (Donate and the dollar sign, one digit, the word monthly), and it gets there with an elastic.out.
| Name | File | Default | What it changes |
|---|---|---|---|
AMOUNTS | script.js | 10, 25, 50, 100 | The four amount pills, in dollars. |
START_AMOUNT | script.js | 25 | The amount chosen when it opens. |
LITRES_PER_DOLLAR | script.js | 15 | How many litres of clean water one dollar brings. |
LITRES_PER_DAY | script.js | 20 | A family’s litres per day, to count the days. |
FULL_AT | script.js | 100 | The amount that fills the can to the brim. |
STIFFNESS | script.js | 320 | The spring of the indicator sliding between the amounts. |
DAMPING | script.js | 25 | Lower lets it pass the amount and come back. |
WAVE | script.js | 4.5 | The height of the surface wave when the amount changes. |
SWELL | script.js | 1.04 | How much the pressed Donate button swells. |
SPEED | script.js | 1 | The speed of the round on its own. |
AUTO | script.js | true | The picker using itself until someone touches it. |
--accent | style.css | #1f6fe0 | The blue of the brand, the ring and the glow. |
--water-top | style.css | #6cc0ff | The water at the surface. |
--water-deep | style.css | #1c5fd4 | The water at the bottom of the can. |
--button | style.css | #0e1a2b | The colour of the Donate button. |
On the Donate page of a charity, an association, a fundraiser or an open source project, where the donor picks how much and how often and sees at once what the money does. The can can be swapped for the drawing of the cause (a stack of books, a plate, a tree) keeping the same spring.
The card narrows to the screen edge minus 24 pixels and the title, pills, can, digits and button get shorter with the height of the box. Touch does what the mouse does: the pill squashes under the finger, Other opens the field with the number keyboard and the button swells under the finger.
No springs, waves or self-running round: the card fades in, the indicator and the pill jump straight to their place, the water is already at the amount’s level and still, the digits change without rolling and the button fades to Thank you.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 12 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.