
The elastic button
Buttons, Hover, Text
A flat’s rent split between three flatmates on a single bar: three orange stretches with initials and percentage, and two white dividers to drag. Moving a divider widens and narrows the two stretches beside it, the percentages and the three dollar shares change as you drag and the sum always stays the rent; “Equal” and “By room size” send the dividers back to their place on a spring.
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>
<!--
"Rent split slider" 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>Rent split slider</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 rent split between three flatmates on one bar: two dividers to drag, the shares rolling
and the total staying put -->
<section class="rs" data-rs aria-label="Split the rent">
<header class="rs__head"><strong>Split the rent</strong><span data-outtotal>$2,400 a month</span></header>
<div class="rs__bar" data-bar>
<div class="rs__part" data-part="0"><b>AK</b><i data-outpct>40%</i></div>
<div class="rs__part" data-part="1"><b>JO</b><i data-outpct>32%</i></div>
<div class="rs__part" data-part="2"><b>MI</b><i data-outpct>28%</i></div>
<button type="button" class="rs__grip" data-grip="0" role="slider" aria-label="Divider between Aiko and Jonas" aria-valuemin="15" aria-valuemax="70" aria-valuenow="40"><i></i></button>
<button type="button" class="rs__grip" data-grip="1" role="slider" aria-label="Divider between Jonas and Mira" aria-valuemin="30" aria-valuemax="85" aria-valuenow="72"><i></i></button>
</div>
<ul class="rs__who">
<li><span>Aiko</span><strong data-outsum>$960</strong></li>
<li><span>Jonas</span><strong data-outsum>$768</strong></li>
<li><span>Mira</span><strong data-outsum>$672</strong></li>
</ul>
<footer class="rs__foot">
<button type="button" class="rs__chip" data-preset="size" aria-pressed="true">By room size</button>
<button type="button" class="rs__chip" data-preset="equal" aria-pressed="false">Equal</button>
<span class="rs__note"><span data-outnote>Adds up to $2,400</span></span>
</footer>
</section>
<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.
26 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 “Rent split slider” from Animorio and fit it into my siteThe state is the position of the two dividers as percentages. The three widths, the three percentages and the three shares come from them; dragging, using the keyboard or picking a preset changes only those two numbers.
Each divider captures the pointer on touch: the finger’s position on the bar becomes a whole percentage, kept between the minimum of whoever is on the left and of whoever is on the right.
The first two shares are rounded to the dollar, the third takes what is left of the rent: that way the three amounts always add up to the total, even with three thirds that do not.
“Equal” and “By room size” animate the two numbers to their values on an elastic spring, redrawing the bar on every frame; the pill lights up by itself whenever the dividers sit on those values.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #ff6a3d | The colour of the bar (the three shades come from it). |
RENT | script.js | 2400 | The monthly rent to split. |
MIN | script.js | 15 | Everyone’s minimum share, as a percentage. |
SPRING | script.js | 1 | How much the dividers bounce when you let go or pick a preset. |
LOOP | script.js | true | Left alone, the demo’s pointer drags the dividers and then starts again. |
In a household expenses app or one for finding flatmates, when rent is not split equally because the rooms are not equal; the same three-way bar with two dividers carries a budget across three lines, a project’s time across three phases, three partners’ stakes or a portfolio’s allocation.
The card is at most 344 pixels wide and about 250 tall, and narrows with the screen. Every divider has a touch area 28 pixels wide and 60 tall, larger than the visible bar, and the bar does not scroll the page while you drag.
Dragging works the same; the presets put the dividers in place at once, with no spring, and there is no bounce on release. On entering the bar is already split. 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.6 KB; the libraries: GSAP 28 KB.
Tested on 29 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.