
The elastic button
Buttons, Hover, Text
One button, one gesture, in the simple style of product interface pieces: the black «Filters» pill with the three-slider icon; on tap the three knobs glide to new places one after the other, each overshooting by a pixel, their tracks fill in the accent colour behind them and the number of active filters arrives beside the word. On a second tap everything goes home.
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>
<!--
"Filters sliders button" 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 Filters button with the sliders gliding into place</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>
<!-- one button, one gesture: the three little slider knobs glide to new places, the tracks fill, a count arrives -->
<button class="filters" type="button" data-filters aria-pressed="false" aria-label="Filters">
<span class="filters__body" data-body>
<svg class="filters__icon" viewBox="0 0 32 32" aria-hidden="true" data-icon>
<g data-row>
<line class="filters__track" x1="6" y1="9" x2="26" y2="9"/>
<line class="filters__fill" data-fill x1="6" y1="9" x2="6" y2="9"/>
<rect class="filters__knob" data-knob x="18.4" y="5.5" width="3.2" height="7" rx="1.6"/>
</g>
<g data-row>
<line class="filters__track" x1="6" y1="16" x2="26" y2="16"/>
<line class="filters__fill" data-fill x1="6" y1="16" x2="6" y2="16"/>
<rect class="filters__knob" data-knob x="10.4" y="12.5" width="3.2" height="7" rx="1.6"/>
</g>
<g data-row>
<line class="filters__track" x1="6" y1="23" x2="26" y2="23"/>
<line class="filters__fill" data-fill x1="6" y1="23" x2="6" y2="23"/>
<rect class="filters__knob" data-knob x="15.4" y="19.5" width="3.2" height="7" rx="1.6"/>
</g>
</svg>
<span class="filters__label" data-label>Filters</span>
<span class="filters__slot" data-slot aria-hidden="true">
<span class="filters__badge" data-badge><span class="filters__count" data-count>3</span></span>
</span>
</span>
</button>
</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.
13 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 “Filters sliders button” from Animorio and fit it into my siteEach row of the icon is a track, a coloured track over it and a rounded rect for the knob. The knob has a border in the pill’s colour with paint-order stroke: it cuts the track by itself, with no masks.
GSAP does not animate the attributes one by one: it animates one object per row (centre, width, fill, opacity) and a single function rewrites x, width and x2. That way the knob can stretch while it runs and stay centred, and the coloured track never passes it.
Each run is four tweens: 0.6 units the wrong way, the run with back.out (the pixel past the mark), the width rising to 4.6 and back to 3.2 with elastic.out. The three knobs start 70 milliseconds apart.
The number’s capsule sits in a slot zero wide: the slot opens with back.out to the capsule’s width measured beforehand, the capsule grows and the digit rolls up from below. On the way out the order is reversed: first the digit, then the capsule, then the room.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #c4f04a | The colour of the filled tracks and of the count. |
LABEL | script.js | Filters | The word on the pill. |
COUNT | script.js | 3 | How many filters the count says once they are on. |
SPRING | script.js | 1 | How springy the knobs and the pill are: 0.4 calm, 2 very bouncy. |
SPEED | script.js | 1 | The speed of everything: 2 twice as fast, 0.5 half. |
HOLD | script.js | 2.2 | How many seconds each state stays when the button plays by itself. |
AUTO | script.js | true | The button plays the gesture by itself until someone touches it. |
For the button that opens or applies the filters in a catalogue, a search or a dashboard table: the moved knobs and the count say by themselves that the list is now filtered.
On the phone the pill and the icon take their size from the screen (clamp on the shorter side); there is no hover, everything else is the same.
The icon fades out and back in with the knobs already in their new places and the tracks already filled; the count fades in, with no springs or movement.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 4.2 KB; the libraries: GSAP 28 KB.
Tested on 1 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.