
The elastic button
Buttons, Hover, Text
A calculator that really works, its keys pressing on a spring. Each digit steps into the display from below and settles, the chosen operation stays lit blue until the second number arrives, and on equals the sum moves up, small, while the result rolls in digit after digit. It works from the keyboard too.
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>
<!--
"Pocket calculator" 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>Pocket calculator</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 pocket calculator: the keys press on a spring, each digit steps into the display
and on equals the sum moves up, small, while the result rolls in -->
<section class="cl" data-cl aria-label="Calculator">
<div class="cl__screen">
<span class="cl__sum"><span data-outsum></span></span>
<output class="cl__value" data-outvalue aria-live="polite">0</output>
</div>
<div class="cl__pad">
<button class="cl__key is-fn" type="button" data-key="clear" aria-label="Clear"><span>AC</span></button>
<button class="cl__key is-fn" type="button" data-key="sign" aria-label="Plus or minus"><span>±</span></button>
<button class="cl__key is-fn" type="button" data-key="percent" aria-label="Percent"><span>%</span></button>
<button class="cl__key is-op" type="button" data-key="/" aria-label="Divide"><span>÷</span></button>
<button class="cl__key" type="button" data-key="7"><span>7</span></button>
<button class="cl__key" type="button" data-key="8"><span>8</span></button>
<button class="cl__key" type="button" data-key="9"><span>9</span></button>
<button class="cl__key is-op" type="button" data-key="*" aria-label="Multiply"><span>×</span></button>
<button class="cl__key" type="button" data-key="4"><span>4</span></button>
<button class="cl__key" type="button" data-key="5"><span>5</span></button>
<button class="cl__key" type="button" data-key="6"><span>6</span></button>
<button class="cl__key is-op" type="button" data-key="-" aria-label="Minus"><span>−</span></button>
<button class="cl__key" type="button" data-key="1"><span>1</span></button>
<button class="cl__key" type="button" data-key="2"><span>2</span></button>
<button class="cl__key" type="button" data-key="3"><span>3</span></button>
<button class="cl__key is-op" type="button" data-key="+" aria-label="Plus"><span>+</span></button>
<button class="cl__key is-wide" type="button" data-key="0"><span>0</span></button>
<button class="cl__key" type="button" data-key="." aria-label="Decimal point"><span>.</span></button>
<button class="cl__key is-eq" type="button" data-key="=" aria-label="Equals"><span>=</span></button>
</div>
</section>
<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>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.
29 values to change
Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI
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 “Pocket calculator” from Animorio and fit it into my siteFour things in memory: the number being typed (as text), the one before, the operation waiting and whether the next digit starts afresh. An operation pressed after the second number works the pending sum out first, as real calculators do.
On every key the number is rewritten, one character per element, with thousands separators. While typing only the last digit animates, from below; on a result they all rise, staggered by four hundredths of a second.
Each key is a button with data-key. On press GSAP takes it from scale 0.88 to 1 on an elastic spring; the waiting operation takes a class that keeps it lit.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #3b6cf6 | The colour of the operation keys and of equals. |
PRESS | script.js | 0.55 | How long a key takes to come back after a press. |
SPRING | script.js | 1 | How much keys and digits bounce. |
Inside an expenses app, a back-office tool, a quote builder, a shop’s till; on a site selling by the metre or the kilo, next to the price; and as the keypad for any number entered by hand, from a bill to split to a tip.
The calculator is at most 244 pixels wide and about 340 tall; on low screens the keys get shorter. Each key is over 50 pixels wide: easy to press with a thumb.
The keys do not squash and the digits do not rise: the number changes in place and the sum appears already in the small line. The display does not shake on an error. The demo’s pointer does not start.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 5.4 KB; the libraries: GSAP 28 KB.
Tested on 26 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.
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.