
The elastic button
Buttons, Hover, Text
The night card of a wellness app, on near black and in a single colour in four tones: the stepped hypnogram draws itself from the left, the score ring fills and the phase durations roll up. Dragging a finger across the chart, a line reads the time and the phase, the label follows a beat behind and the phase lights up in the legend and the list.
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>
<!--
"Sleep phases chart" 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 sleep chart with phases to scrub through</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>
<!-- last night's sleep in a wellness app: the hypnogram draws itself step by step, a finger dragged across it
reads the time and the phase, the phase lights up in the legend and in the list, the score fills its ring -->
<section class="sleep" data-card aria-label="Nightfern, last night's sleep">
<header class="sleep__head">
<div class="sleep__title">
<svg class="sleep__mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M15.5 3.6a8.6 8.6 0 1 0 4.9 13.6A7.2 7.2 0 0 1 15.5 3.6Z"/></svg>
<div>
<p class="sleep__brand">Nightfern</p>
<p class="sleep__night">Last night · Tue 27</p>
</div>
</div>
<div class="score" aria-label="Sleep score">
<svg class="score__ring" viewBox="0 0 52 52" aria-hidden="true">
<circle class="score__track" cx="26" cy="26" r="22"/>
<circle class="score__fill" cx="26" cy="26" r="22" data-ring/>
</svg>
<span class="score__num" data-score>0</span>
</div>
</header>
<div class="chart" data-chart>
<svg class="chart__svg" viewBox="0 0 320 128" aria-hidden="true" data-svg>
<g class="chart__rows" data-rows></g>
<g class="chart__links" data-links></g>
<g class="chart__steps" data-steps></g>
<g class="chart__axis" data-axis></g>
<line class="chart__cursor" x1="0" y1="2" x2="0" y2="110" data-cursor/>
<circle class="chart__knob" cx="0" cy="0" r="3.4" data-knob/>
</svg>
<div class="tip" data-tip><span class="tip__time" data-tip-time>02:14</span><span class="tip__phase" data-tip-phase>Deep</span></div>
<p class="chart__hint" data-hint>Drag across the night</p>
</div>
<ul class="phases" data-phases></ul>
<footer class="sleep__foot">
<span>Time asleep</span>
<strong data-asleep>0h 00m</strong>
</footer>
</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"/></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.
24 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 “Sleep phases chart” from Animorio and fit it into my siteThe night is a list of phases with their minutes, scaled to the 475 minutes between 23:10 and 07:05: each phase becomes a rounded rectangle six units tall on its row, and between one rectangle and the next a thin vertical line makes the step.
On arrival the rectangles start at scaleX 0 with the origin on the left and stretch one after another with a stagger that divides DRAW_TIME by their number; the step lines appear at the same pace, a little later.
The finger’s x is turned into viewBox coordinates, then into minutes: the phase that holds them is found, the dotted line and the knob move there and the label follows with gsap.quickTo, which gives it the soft delay.
When the phase changes, its name in the legend and its row in the list take the full colour, its bar gives a jolt in height with back.out and the rectangles of the other phases drop to 35% opacity.
| Name | File | Default | What it changes |
|---|---|---|---|
APP | script.js | Nightfern | The name of the invented wellness app. |
SCORE | script.js | 84 | The sleep score that fills the ring. |
ACCENT | script.js | #8f91ff | The colour of the phases, in four tones, and of the ring. |
DRAW_TIME | script.js | 1.6 | The seconds the hypnogram takes to draw itself. |
LAG | script.js | 0.35 | The seconds the label takes to catch up with the finger. |
PAUSE | script.js | 1.2 | The seconds the autopilot rests on a phase. |
For a wellness or sports app, the data page of a smart ring or watch, a health dashboard, anywhere a night or a day is read hour by hour.
The card takes almost the whole width and the chart scales with it thanks to the viewBox; under 380 pixels the list tightens. A dragged finger does what the mouse does.
The chart, the ring and the durations are already in place, without drawing; when dragging, the line and the label jump straight to the point, with no delay or jolts, and the drawn pointer is absent.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.5 KB; the libraries: GSAP 28 KB.
Tested on 27 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.