Skip to content
animorio
IT
All components

Hopping period picker

Pickers, HoverGSAP, CSS onlyMediumCompressed weight: Demo 4.6 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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.

15 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 “Hopping period 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 white there is only a very light grey track with three periods, Day, Week and Month, and below it a small line saying what is being shown. On the chosen period sits a red pill, the only colour. Picking another one, the pill does not slide: it crouches for a moment, lifts a few pixels and passes over the track on an arc, while below it stays its shadow, paler and smaller the higher it goes. It arrives, squashes as it lands, drops one pixel too far and comes back, and the spring returns it to its shape. The label it leaves loses weight, the one it lands on gains it, widens slightly and sinks one pixel with the pill; on the track the red outline of the spot where it landed lingers for a moment, grows and fades like the mark of a stamp. The line below changes: the old one rises away before the new one arrives. With the mouse over another period the pill leans a couple of pixels towards it; pressing the chosen one makes it squeeze and come back. A drawn pointer tries Month, Day and Week; it works with touch and the arrow keys.

How it works

Two curves for a hop

The 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.

Crouching and landing

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 stays below

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.

The mark it leaves

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.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#d9472bThe colour of the pill and of the mark it leaves where it lands.
HOPscript.js12How many pixels the pill lifts in the hop.
HOP_TIMEscript.js0.46The seconds of the hop from one period to the next.
SQUASHscript.js1How much the pill squashes at take-off and landing.
PAUSEscript.js1.5The autopilot’s seconds on each period.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

No hop: the pill fades out and back in on the new period, the labels change weight and colour without moving.

Pitfalls

  • A hop made with one curve on x and one on y in the same tween looks stiff: you need two tweens on y, up and down, overlapping the one on x.
  • The squash needs its origin at the bottom, otherwise the pill lifts off the track as it squashes.
  • The leaning pill uses xPercent, so it does not fight the hop’s x.

Libraries

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.

Testing

Tested on 30 October 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