
The elastic button
Buttons, Hover, Text
The «Sort by» menu of a ceramics shop’s catalogue, on white, in the style of real product interface pieces: the pill opens into a menu on a spring, a grey highlight slides under the option, the green check draws itself on the chosen order and the six product cards travel to their new places with Flip, lifting a little on the way, while the price or rating they are sorted by lights up one after another.
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>
<!--
"Sort by menu" 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 Sort by menu that reorders the catalogue</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 catalogue of a ceramics shop: the Sort by pill opens a menu on a spring, the highlight follows the pointer,
the check moves to the chosen order and the six products below travel to their new places with Flip,
lifting a little on the way, while the value they are sorted by lights up -->
<section class="card" data-card aria-label="Shop catalogue">
<header class="head">
<span class="mark" aria-hidden="true">
<svg viewBox="0 0 24 24"><path d="M8 4h8M9 4c0 3-3.5 4.5-3.5 9a6.5 6.5 0 0 0 13 0C18.5 8.5 15 7 15 4M7 14h10"/></svg>
</span>
<span class="head__text">
<span class="head__name" data-name>Kilnhouse</span>
<span class="head__sub" data-sub>6 pieces</span>
</span>
<div class="sort" data-sort>
<button class="pill" type="button" data-pill aria-haspopup="listbox" aria-expanded="false" aria-controls="sort-menu">
<span class="pill__key">Sort</span>
<span class="pill__win" data-win><span class="pill__val" data-val>Newest</span></span>
<svg class="pill__chev" data-chev viewBox="0 0 24 24" aria-hidden="true"><path d="m7 10 5 5 5-5"/></svg>
</button>
<div class="menu" id="sort-menu" data-menu role="listbox" aria-label="Sort by" tabindex="-1">
<span class="menu__title">Sort by</span>
<span class="menu__hl" data-hl aria-hidden="true"></span>
<div class="menu__list" data-list></div>
</div>
</div>
</header>
<ul class="grid" data-grid aria-live="polite"></ul>
</section>
<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="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/Flip.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.
20 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 “Sort by menu” from Animorio and fit it into my siteThe menu sits in absolute position under the pill, with transform-origin near its top-right corner: it opens with a fromTo of scale from 0.92, y from minus eight pixels and opacity, with back.out, and the options arrive with a three-hundredths stagger. Closed, it is hidden with visibility, so it takes neither taps nor tabs.
A single grey pill behind the options: on every pointerenter or focus it goes to the option’s offsetTop plus the list’s with back.out, and when the pointer leaves the menu it goes back to the chosen option. One element for all options, instead of a hover per option, shows the movement.
The checks are paths with a strokeDasharray as long as themselves: the old one is wiped by taking strokeDashoffset to the length, the new one is drawn from there to zero. The pill’s label is a clone coming in from below with yPercent while the old one leaves upwards, and the window takes the width of the new label, measured first with an invisible element.
Flip.getState reads where the six cards are, the new order puts them back in the grid with appendChild and Flip.from takes them from the old position to the new one with power3.inOut and a stagger. The lift lives on each card’s inner child, scale and box-shadow in a small timeline, so Flip’s transform and the lift’s do not cancel each other.
| Name | File | Default | What it changes |
|---|---|---|---|
SHOP | script.js | Kilnhouse | The shop’s name at the top of the card. |
ACCENT | script.js | #2f6b52 | The colour of the check, of the New labels and of the value the cards are sorted by. |
FLIP_TIME | script.js | 0.75 | The seconds each product takes to reach its new place. |
STAGGER | script.js | 0.035 | The seconds between one product starting and the next. |
LIFT | script.js | 1.04 | How much a product lifts while it travels (1 means none). |
MENU_SPRING | script.js | 1.6 | The menu’s bounce when it opens (0 means none). |
PAUSE | script.js | 1.1 | The seconds the autopilot waits on each order. |
For an online shop’s catalogue, a list of products, rooms, events or articles, and anywhere people can choose the order things are shown in.
The card takes the full width minus the margins and the three columns narrow; below 380 pixels the word «Sort» leaves the pill and the menu gets a little narrower, so it stays inside the card. Options are 36 pixels tall for a finger.
No springs and no travel: the menu fades in and out, the check changes at once, the pill’s label changes in place and the grid fades out and back in already in the new order. The drawn pointer stays hidden.
GSAP 3.15.0, Flip (GSAP) 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 8.2 KB; the libraries: GSAP + Flip 37 KB.
Tested on 8 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.