Skip to content
animorio
IT
All components

Donation amount picker

Pickers, Hover, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>&nbsp;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>

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.

45 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 “Donation amount picker” 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 a white ground there is a single white card with wide corners, its one pixel edge catching the light at the top, a soft layered shadow with a thread of blue and a very fine grain. At the top Springline in small letters with its drop and the title Give clean water. Under it the One-time / Monthly switch: a white pill on a light grey tray, sliding from one to the other, stretching for a moment and settling with an elastic. Then the row of amounts, $10, $25, $50, $100 and Other: the grey pills lighten on hover and the figure rises by a pixel; the chosen one turns white with a blue figure, and a blue ring slides over it with two edges on two springs, the leading one quicker, so it stretches the way it runs and closes up as it arrives. Tapping Other widens its pill, the word fades and in its place the field opens with the dollar sign, where you type the figure. Below, in a pale blue panel, the drawn water can: inside, the water rises on a spring to the level of the amount (full at 100 dollars), the surface makes a wave that calms by itself and tilts as if the can had been shaken, three bubbles rise, the cap wobbles and the litre marks turn white as the water covers them. Beside it Your impact, the litres of safe water in large figures and the days for a family, rolling like counters and settling by a pixel; with Monthly, every month is added. At the bottom the dark Donate $25 button: the digits roll, the word monthly comes in and the button widens or narrows on a spring. Pressed, it swells with a blue glow and becomes Thank you with the check drawing itself, then comes back. Until someone touches it, the picker chooses 50, switches to Monthly, chooses 100, opens Other and types 75, goes back to 10 and 25, donates and returns to One-time.

How it works

The indicator on two springs

The 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 opening up

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 water in the can

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.

Digits and button

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.

Values to change

NameFileDefaultWhat it changes
AMOUNTSscript.js10, 25, 50, 100The four amount pills, in dollars.
START_AMOUNTscript.js25The amount chosen when it opens.
LITRES_PER_DOLLARscript.js15How many litres of clean water one dollar brings.
LITRES_PER_DAYscript.js20A family’s litres per day, to count the days.
FULL_ATscript.js100The amount that fills the can to the brim.
STIFFNESSscript.js320The spring of the indicator sliding between the amounts.
DAMPINGscript.js25Lower lets it pass the amount and come back.
WAVEscript.js4.5The height of the surface wave when the amount changes.
SWELLscript.js1.04How much the pressed Donate button swells.
SPEEDscript.js1The speed of the round on its own.
AUTOscript.jstrueThe picker using itself until someone touches it.
--accentstyle.css#1f6fe0The blue of the brand, the ring and the glow.
--water-topstyle.css#6cc0ffThe water at the surface.
--water-deepstyle.css#1c5fd4The water at the bottom of the can.
--buttonstyle.css#0e1a2bThe colour of the Donate button.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • An input inside a button is not valid HTML and the click never reaches the field: Other is a button and the field sits over it as a sibling, in the same flexible slot, hidden with visibility while closed.
  • The indicator measures the pill every frame only while awake; while Other widens it stays awake even if the springs are still, otherwise it fell asleep halfway and stayed narrow.
  • The button’s width cannot be read from the button while the digit boxes are still changing width: it is worked out from the parts measured once, and measured again when the fonts arrive.
  • In the self-running round the field takes no focus (the preview on the page would steal it from the page): the digits are written into the value and cleaned like a real keystroke.
  • A button pressed with the mouse already gives its own press: the short press on submit is only for Enter, recognised by the time since the last pointerdown.

Libraries

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.

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