
The elastic button
Buttons, Hover, Text
A three-period picker, Day, Week and Month, alone on white, in a minimal style: the pill marking the choice does not slide, it hops. It crouches, lifts a few pixels leaving its shadow on the track, reaches the new period, squashes as it lands, goes one pixel too far and settles; the chosen label gains weight and the track keeps for a moment the mark it left, like a stamp lifting.
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>
<!--
"Hopping period 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>The period picker with the pill that hops and lands</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 Day / Week / Month picker: the pill does not slide, it lifts off, hops over and lands on the new period -->
<div class="pick" data-pick>
<div class="seg" role="radiogroup" aria-label="Period" data-seg>
<span class="seg__shadow" data-shadow aria-hidden="true"></span>
<span class="seg__mark" data-mark aria-hidden="true"></span>
<span class="seg__pill" data-pill aria-hidden="true"></span>
<button class="seg__opt" type="button" role="radio" aria-checked="false" tabindex="-1" data-opt="0"><span>Day</span></button>
<button class="seg__opt" type="button" role="radio" aria-checked="true" tabindex="0" data-opt="1"><span>Week</span></button>
<button class="seg__opt" type="button" role="radio" aria-checked="false" tabindex="-1" data-opt="2"><span>Month</span></button>
</div>
<p class="pick__note" aria-live="polite"><span data-note>Showing this week</span></p>
</div>
<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.
15 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 “Hopping period picker” from Animorio and fit it into my siteThe pill’s x goes to the new period on a single power2.inOut curve, while its y rises with power2.out for half the time and falls with power2.in for the other half: two overlapping tweens draw the arc. Height and duration grow a little with the distance, so a long hop is higher and slower.
Before the hop the pill squashes by a few points with its origin at the bottom, the anticipation; on landing it squashes more, then an elastic.out brings it back into shape, while a small yoyo on y takes it one pixel past the track and back.
The shadow is a separate blurred element on the track: it follows the pill’s x and, while the pill rises, gets more visible but smaller, then disappears under the pill again when it lands.
As it lands, a thin outline in the pill’s colour appears beneath it, grows by ten per cent and fades: it is the only extra sign, and it says where the pill landed.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #d9472b | The colour of the pill and of the mark it leaves where it lands. |
HOP | script.js | 12 | How many pixels the pill lifts in the hop. |
HOP_TIME | script.js | 0.46 | The seconds of the hop from one period to the next. |
SQUASH | script.js | 1 | How much the pill squashes at take-off and landing. |
PAUSE | script.js | 1.5 | The autopilot’s seconds on each period. |
For picking the period of a dashboard or a calendar, the monthly and yearly plans of a pricing page, the views of an app with few options, when the change should be felt without adding anything.
The track takes 86 per cent of the width up to 312 pixels and is also sized on the height; the pill’s positions are in pixels and are measured again on resize, even half way through a hop. Touch picks like a click; the leaning pill is only there with a mouse.
No hop: the pill fades out and back in on the new period, the labels change weight and colour without moving.
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 30 October 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.