
The elastic button
Buttons, Hover, Text
The “Randomize” button of a palette generator: on every tap the die inside the pill hops, makes a turn and changes face, and the five colour stripes renew one after the other from the bottom, with their hex codes rolling. Every stripe has a padlock: the locked colour stays where it is while the others change.
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>
<!--
"Randomize 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>Randomize button</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">
<!-- the Randomize button of a palette generator: the die tumbles inside the pill, the five
colours change one after the other with their codes rolling, and a locked colour stays -->
<i class="frame" data-frame aria-hidden="true"></i>
<div class="rz" data-rz>
<div class="rz__palette" data-palette role="group" aria-label="Palette">
<div class="rz__sw" data-sw><i class="rz__wash" data-wash></i><button class="rz__lock" type="button" data-lock aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="rz__shackle" d="M5.250 7.250V5.250a2.750 2.750 0 0 1 5.500 0v2"></path><rect x="3.500" y="7.250" width="9" height="6.250" rx="1.800"></rect></svg></button><span class="rz__hex"><b data-outhex></b></span></div>
<div class="rz__sw" data-sw><i class="rz__wash" data-wash></i><button class="rz__lock" type="button" data-lock aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="rz__shackle" d="M5.250 7.250V5.250a2.750 2.750 0 0 1 5.500 0v2"></path><rect x="3.500" y="7.250" width="9" height="6.250" rx="1.800"></rect></svg></button><span class="rz__hex"><b data-outhex></b></span></div>
<div class="rz__sw" data-sw><i class="rz__wash" data-wash></i><button class="rz__lock" type="button" data-lock aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="rz__shackle" d="M5.250 7.250V5.250a2.750 2.750 0 0 1 5.500 0v2"></path><rect x="3.500" y="7.250" width="9" height="6.250" rx="1.800"></rect></svg></button><span class="rz__hex"><b data-outhex></b></span></div>
<div class="rz__sw" data-sw><i class="rz__wash" data-wash></i><button class="rz__lock" type="button" data-lock aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="rz__shackle" d="M5.250 7.250V5.250a2.750 2.750 0 0 1 5.500 0v2"></path><rect x="3.500" y="7.250" width="9" height="6.250" rx="1.800"></rect></svg></button><span class="rz__hex"><b data-outhex></b></span></div>
<div class="rz__sw" data-sw><i class="rz__wash" data-wash></i><button class="rz__lock" type="button" data-lock aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="rz__shackle" d="M5.250 7.250V5.250a2.750 2.750 0 0 1 5.500 0v2"></path><rect x="3.500" y="7.250" width="9" height="6.250" rx="1.800"></rect></svg></button><span class="rz__hex"><b data-outhex></b></span></div>
</div>
<button class="rz__btn" type="button" data-go>
<span class="rz__in">
<span class="rz__die" data-die><svg viewBox="0 0 20 20" aria-hidden="true"><rect x="2" y="2" width="16" height="16" rx="4.200"></rect><g data-pips><circle cx="6.400" cy="6.400" r="1.350"></circle><circle cx="13.600" cy="6.400" r="1.350"></circle><circle cx="6.400" cy="10" r="1.350"></circle><circle cx="10" cy="10" r="1.350"></circle><circle cx="13.600" cy="10" r="1.350"></circle><circle cx="6.400" cy="13.600" r="1.350"></circle><circle cx="13.600" cy="13.600" r="1.350"></circle></g></svg></span>
<span class="rz__word">Randomize</span>
</span>
<i class="rz__sheen" data-sheen></i>
</button>
</div>
<span class="live" aria-live="polite" data-live></span>
<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.
10 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 “Randomize button” from Animorio and fit it into my siteA seeded generator always gives the same run of numbers. From it come a starting hue, the step it walks from one stripe to the next, a lightness climbing from dark to light and, six times out of ten, one far colour as an accent.
Every stripe carries a veil of the new colour, zero tall and anchored to the bottom: GSAP raises it, staggered from stripe to stripe, and at the end the stripe takes that colour and the veil goes back to zero. The code rolls and the lettering colour is picked from the luminance.
The die is a square with seven pips: every face lights some of them. During the turn the face changes three times and the landing squashes it for a moment. A locked stripe skips the change and shakes its padlock.
| Name | File | Default | What it changes |
|---|---|---|---|
SEED | script.js | 7 | The number the palettes grow from: change it and the run of colours is another one. |
SATURATION | script.js | 0.62 | How vivid the colours are. |
STAGGER | script.js | 0.07 | How many seconds pass between one stripe and the next. |
SPRING | script.js | 1 | How much the die and the button bounce. |
In a design tool, in a generator of palettes, gradients, avatars, names or themes; in a brand or site configurator; anywhere a button offers another random possibility and part of the result should be kept.
The band is at most 300 pixels wide and at most 132 tall (a third of the screen when it is short), the pill is 50 tall and 172 wide. The padlocks are 30 pixel circles: everything is thumb-sized and nothing depends on hover.
Colours and codes change at once, the die shows its new face without hopping or turning, the button and the padlocks do not bounce. 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.9 KB; the libraries: GSAP 28 KB.
Tested on 28 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.