
The layered button
Buttons, Hover, Physics
One gesture, drag: the three panes of a small code editor, Files, Editor and Preview, in a rounded frame on white. The thin handles thicken under the pointer, follow the finger with a rubber band at the limits, glide a little when you let go and settle on the 25, 50 and 75 per cent lines; a side pane pulled past its edge closes, pulled back out it opens again.
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>
<!--
"The resizable panels" 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 resizable panels</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/standard.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist-mono@5.3.0/index.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="stage">
<!-- the resizable panels of a small code editor: Files, Editor and Preview side by side. The two thin handles
thicken under the pointer, follow the finger with a rubber band at the limits, glide a little on release and
settle on the 25, 50 and 75 lines; pull a side panel past its edge and it closes, pull it back and it opens -->
<div class="split" data-split>
<div class="split__frame" data-frame>
<section class="pane pane--files" data-pane="files" aria-label="Files">
<div class="pane__in">
<header class="pane__head"><span class="pane__title">Files</span></header>
<ul class="tree">
<li class="tree__row tree__row--dir"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 4.6c0-.7.5-1.2 1.2-1.2h3l1.4 1.5h5.2c.7 0 1.2.5 1.2 1.2v5.6c0 .7-.5 1.2-1.2 1.2H3.2c-.7 0-1.2-.5-1.2-1.2Z"/></svg><span>src</span></li>
<li class="tree__row tree__row--on"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2h5.4L12.5 5v8.6c0 .2-.2.4-.4.4H4c-.2 0-.4-.2-.4-.4V2.4c0-.2.2-.4.4-.4Z M9.2 2.2V5.2h3"/></svg><span>App.tsx</span></li>
<li class="tree__row"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2h5.4L12.5 5v8.6c0 .2-.2.4-.4.4H4c-.2 0-.4-.2-.4-.4V2.4c0-.2.2-.4.4-.4Z M9.2 2.2V5.2h3"/></svg><span>Invoice.tsx</span></li>
<li class="tree__row"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2h5.4L12.5 5v8.6c0 .2-.2.4-.4.4H4c-.2 0-.4-.2-.4-.4V2.4c0-.2.2-.4.4-.4Z M9.2 2.2V5.2h3"/></svg><span>theme.css</span></li>
<li class="tree__row"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2h5.4L12.5 5v8.6c0 .2-.2.4-.4.4H4c-.2 0-.4-.2-.4-.4V2.4c0-.2.2-.4.4-.4Z M9.2 2.2V5.2h3"/></svg><span>README.md</span></li>
</ul>
</div>
</section>
<section class="pane pane--editor" data-pane="editor" aria-label="Editor">
<div class="pane__in">
<header class="pane__head"><span class="pane__tab">App.tsx</span></header>
<pre class="code"><span class="ln">1</span><span class="k">import</span> { Invoice } <span class="k">from</span> <span class="s">'./Invoice'</span>
<span class="ln">2</span>
<span class="ln">3</span><span class="k">export default function</span> <span class="f">App</span>() {
<span class="ln">4</span> <span class="k">return</span> (
<span class="ln">5</span> <<span class="f">Invoice</span>
<span class="ln">6</span> client=<span class="s">"Northwind"</span>
<span class="ln">7</span> total={<span class="n">1240</span>}
<span class="ln">8</span> due=<span class="s">"Nov 14"</span> />
<span class="ln">9</span> )
<span class="ln">10</span>}</pre>
</div>
</section>
<section class="pane pane--preview" data-pane="preview" aria-label="Preview">
<div class="pane__in">
<header class="pane__head"><span class="pane__title">Preview</span></header>
<div class="mini">
<span class="mini__who">Northwind</span>
<span class="mini__sum">$1,240.00</span>
<span class="mini__due">Due Nov 14</span>
<span class="mini__btn">Pay invoice</span>
</div>
</div>
</section>
<div class="guide" data-guide="0.25" aria-hidden="true"></div>
<div class="guide" data-guide="0.5" aria-hidden="true"></div>
<div class="guide" data-guide="0.75" aria-hidden="true"></div>
<div class="handle" data-handle="0" role="separator" aria-orientation="vertical" aria-label="Resize Files" tabindex="0" aria-valuemin="0" aria-valuemax="100" aria-valuenow="25"><span class="handle__line"></span><span class="handle__grip"></span></div>
<div class="handle" data-handle="1" role="separator" aria-orientation="vertical" aria-label="Resize Preview" tabindex="0" aria-valuemin="0" aria-valuemax="100" aria-valuenow="25"><span class="handle__line"></span><span class="handle__grip"></span></div>
</div>
<div class="pill" data-pill aria-hidden="true"><span data-pill-name>Files</span><b data-pill-val>25%</b></div>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true">
<g data-ghost-arrow><path d="M5 3.2 18.6 13.4l-6.3.6 3.6 6.7-2.4 1.3-3.6-6.8-4.9 4.2Z"/></g>
<g data-ghost-resize><path class="ghost__bars" d="M9.8 6v12M14.2 6v12M7.4 9 4.2 12l3.2 3M16.6 9l3.2 3-3.2 3"/><path class="ghost__arrows" d="M9.8 6v12M14.2 6v12M7.4 9 4.2 12l3.2 3M16.6 9l3.2 3-3.2 3"/></g>
</svg>
<p class="sr" aria-live="polite" data-live></p>
</div>
</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.
73 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 “The resizable panels” from Animorio and fit it into my siteThe two handles have a position x, a speed v and a target t, as shares of the width. On every frame the spring pulls x towards t (k times the distance minus the damping times the speed), in three sub steps with the time step capped at 1/30 of a second. While you drag the spring is very stiff and has no bounce, so the pane follows the finger one to one; when you let go it softens to STIFFNESS and DAMPING, and below 1 the damping leaves one pixel too many.
The limits of one handle depend on the other: Files and Preview never go below SIDE_MIN, the editor never below EDITOR_MIN. Past a limit the target does not stop: it moves by d times RUBBER over (1 + 6d), so it gives less and less the further you pull. The grip squashes to match, through a CSS variable.
While dragging, the last 90 milliseconds of positions are kept. On release the speed is their slope; the goal is where that speed would carry the handle in INERTIA seconds, kept inside the limits. If one of the SNAPS lines is within SNAP_RANGE, the goal becomes that line and its dashed guide flashes. The spring starts with the finger’s speed, so the handle does not stop and start again: it glides.
If the finger takes Files or Preview below CLOSE_AT, the target jumps to the edge and the pane shuts on the spring; you have to pull a little further, CLOSE_AT plus 4 per cent, to open it again, so it does not flicker at the border. Inside the panes container queries do the work: under 104 pixels the file names go and the icons stay, under 44 everything fades with a touch of blur.
The handles are role separator with aria-valuenow and an aria-valuetext that gives the pane name and its share. Arrow keys move them by 2 per cent, with Shift by 10, Home and End go to the limits, Enter closes and opens the pane. Touching the frame stops the demo pointer, which comes back after seven quiet seconds. With reduced motion the handles go straight to their place, with no spring and no demo pointer.
| Name | File | Default | What it changes |
|---|---|---|---|
START | script.js | [0.25, 0.75] | Where the two handles rest at the start and after a double click, as shares of the width. |
SNAPS | script.js | [0.25, 0.5, 0.75] | The lines the handles settle on when you let go near them. |
SNAP_RANGE | script.js | 0.05 | How close to a line a handle has to land to settle on it. |
SIDE_MIN | script.js | 0.14 | The narrowest Files and Preview can be before they resist. |
EDITOR_MIN | script.js | 0.24 | The narrowest the editor can be. |
CLOSE_AT | script.js | 0.06 | Below this share a side pane closes. |
RUBBER | script.js | 0.32 | How much the handle still gives past a limit: 0 is a wall, 1 is no limit. |
INERTIA | script.js | 0.16 | How far a handle glides after a flick, in seconds of its speed. |
STIFFNESS | script.js | 340 | The stiffness of the spring that settles a released handle. |
DAMPING | script.js | 0.74 | The damping: below 1 the handle overshoots by a pixel before it stops. |
AUTOPLAY | script.js | true | A demo pointer shows the gestures until you touch the panels. |
For any app that puts two or three things side by side: an editor with its preview, an inbox with the open message, a dashboard with its sidebar, a CMS with the text and the page, a design tool with layers and properties.
The frame takes 92 per cent of the width and at most three quarters of the height; below 104 pixels the side panes show only their icons. The handles have an 18 pixel touch area and drag with a finger just as with a mouse; the rest of the frame lets the page scroll.
The handles go straight where you take them, with no spring, rubber band or glide, the pill fades in and the demo pointer does not start.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, Geist Mono (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 8.6 KB; the libraries: GSAP 28 KB.
Tested on 24 October 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.