
The elastic button
Buttons, Hover, Text
The navigation bar of Slow Margins, a made-up weekly newsletter: the mark with the latest issue and how many posts are still unread, the sections Essays, Notes, Reading and About, and Subscribe. Each section has its orange badge with the new posts. Choose one and the dark pill slides over on two springs, the front edge quicker than the back, takes the badge inside, counts the new posts down to a tick and closes the room they leave, while the sections after it draw closer and the line under the name counts down to All caught up.
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>
<!--
"Newsletter nav" 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 newsletter nav whose pill collects the new-post counts</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz-italic.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="stage">
<!-- one gesture: the dark pill slides to a section on two springs, takes the section's new-post badge inside,
counts it down to a tick and closes the gap it leaves; the unread line under the name counts down with it -->
<nav class="nav" data-nav aria-label="Slow Margins">
<span class="nav__grain" aria-hidden="true"></span>
<a class="brand" href="#home" data-brand>
<span class="brand__mark" aria-hidden="true">
<svg viewBox="0 0 30 30">
<rect class="m__tile" x="0.5" y="0.5" width="29" height="29" rx="8.5"></rect>
<path class="m__page" d="M9.5 7.5h7.6l4.4 4.4v10.6H9.5Z"></path>
<path class="m__fold" d="M17.1 7.5v4.4h4.4"></path>
<path class="m__line" data-mline d="M12 15.4h6.9"></path>
<path class="m__line" data-mline d="M12 18.6h4.6"></path>
</svg>
</span>
<span class="brand__text">
<span class="brand__name">Slow Margins</span>
<span class="brand__meta">Issue <span class="roll" data-issue><span>48</span></span><span class="brand__sep">·</span><span class="roll roll--tail" data-tail><span><span class="roll" data-total><span>10</span></span> unread</span></span></span>
</span>
</a>
<div class="links" data-links role="list">
<span class="ghost" data-ghost aria-hidden="true"></span>
<span class="pill" data-pill aria-hidden="true"><span class="pill__press" data-press><span class="pill__face" data-face></span><span class="pill__sheen" data-sheen></span></span></span>
<a class="link" href="#essays" role="listitem" data-link data-new="3">
<span class="link__word">Essays</span>
<span class="slot" data-slot><span class="chip" data-chip><span class="roll" data-num><span>3</span></span><svg class="chip__tick" viewBox="0 0 12 12" aria-hidden="true"><path d="M2.8 6.3 5 8.4l4.2-4.6"></path></svg></span></span>
<span class="sr" data-sr>, 3 new</span>
</a>
<a class="link" href="#notes" role="listitem" data-link data-new="5">
<span class="link__word">Notes</span>
<span class="slot" data-slot><span class="chip" data-chip><span class="roll" data-num><span>5</span></span><svg class="chip__tick" viewBox="0 0 12 12" aria-hidden="true"><path d="M2.8 6.3 5 8.4l4.2-4.6"></path></svg></span></span>
<span class="sr" data-sr>, 5 new</span>
</a>
<a class="link" href="#reading" role="listitem" data-link data-new="2">
<span class="link__word">Reading</span>
<span class="slot" data-slot><span class="chip" data-chip><span class="roll" data-num><span>2</span></span><svg class="chip__tick" viewBox="0 0 12 12" aria-hidden="true"><path d="M2.8 6.3 5 8.4l4.2-4.6"></path></svg></span></span>
<span class="sr" data-sr>, 2 new</span>
</a>
<a class="link is-on" href="#about" role="listitem" data-link data-new="0" aria-current="page">
<span class="link__word">About</span>
</a>
</div>
<button class="sub" type="button" data-sub aria-pressed="false">
<span class="sub__light" data-sublight aria-hidden="true"></span>
<span class="sub__icon" aria-hidden="true">
<svg viewBox="0 0 16 16">
<g data-env><rect x="2" y="3.6" width="12" height="8.8" rx="2"></rect><path d="m2.6 4.6 5.4 4 5.4-4"></path></g>
<path class="sub__tick" data-subtick d="M3.6 8.4 6.6 11.2 12.4 5"></path>
</svg>
</span>
<span class="roll sub__label" data-sublabel><span>Subscribe</span></span>
</button>
</nav>
</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.
35 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 “Newsletter nav” from Animorio and fit it into my siteThe dark pill has no tween: on every frame of the GSAP ticker its left and right edges chase the edges of the chosen section, each on its own damped spring. The leading edge is stiffer (STIFF), the trailing one gets a fraction of it (LAG): on the way the pill stretches, and its speed flattens it slightly.
The edges to reach are read from the section's getBoundingClientRect on every frame, not stored at the start. So when the room of a badge closes and the sections move, or the window is resized, the pill follows them on its spring with no extra work.
Each badge sits in a 22-pixel slot after the word; at rest it is moved to a superscript with x, y and scale. When it is collected a timeline brings it onto the line with a back.out, calls the countdown steps, draws the tick with strokeDashoffset and closes the slot by taking its width to zero.
Each number is a small grid with hidden overflow: the new text enters the same cell from the side it counts towards, the old one leaves from the other with a touch of blur, and the cell's width goes from the old one to the new. The same piece counts the badge down, the unread line, the issue number and Subscribe.
| Name | File | Default | What it changes |
|---|---|---|---|
ISSUE | script.js | 48 | The issue number written under the name. |
STIFF | script.js | 420 | The stiffness of the spring on the pill's leading edge. |
LAG | script.js | 0.55 | How much softer the trailing edge is: lower, and the pill stretches more on the way. |
TICK | script.js | 0.15 | The seconds between one number and the next as the count goes down. |
BOUNCE | script.js | 1.7 | How much the badges and the button bounce. |
HOLD | script.js | 2.4 | The seconds the autopilot leaves Subscribed in view. |
PAUSE | script.js | 0.9 | The seconds of rest between sections in the autopilot. |
--inchiostro | style.css | #19171c | The colour of the pill, the mark and the name. |
--accento | style.css | #f0582c | The orange of the badges and Subscribe. |
--barra | style.css | #fcfbf9 | The paper colour of the bar. |
At the top of a personal blog, a newsletter or an online magazine, when returning readers want to see at once what is new in each section: the badge says how many posts they have not seen yet and the pill clears them as soon as they go in.
Below 600 pixels the bar goes onto two rows: the mark and Subscribe on top, the four sections below, a little narrower on Mona Sans's width axis. The finger chooses like the mouse; without hover the light pill does not appear.
No springs or rolling numbers: the dark pill fades out and back in on the chosen section, numbers and labels change with a fade, the badge fades away and its room closes at once.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, Newsreader (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 10.0 KB; the libraries: GSAP 28 KB.
Tested on 16 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.