
The elastic button
Buttons, Hover, Text
The editor of a writing app on warm white: you select a sentence and the highlight grows word by word, then a dark pill toolbar springs up above it with bold, italic, link, comment and Ask AI. Bold makes the words gain weight on the wght axis, link opens a field inside the toolbar as it widens, Ask AI opens a small menu and the sentence rewrites itself out of random letters; the toolbar follows the selection and goes away when you let go.
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>
<!--
"Selection toolbar" 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 toolbar that follows the selection</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 editor of a writing app: select some words and a dark toolbar is born above them, follows the selection
and acts on it (bold, italic, link, comment, Ask AI) -->
<section class="doc" data-doc aria-label="Quillary editor">
<header class="doc__bar">
<svg class="doc__logo" viewBox="0 0 20 20" aria-hidden="true"><path d="M4.5 15.5c3.4-.6 6.6-3 8.6-6.4l2.4-4.6-4.6 2.4C7.5 8.9 5.1 12.1 4.5 15.5Z"></path><path d="M4.5 15.5 9 11"></path></svg>
<span class="doc__app">Quillary</span>
<span class="doc__sep">/</span>
<span class="doc__path">Launch notes</span>
<span class="doc__chip" data-chip aria-hidden="true"><svg viewBox="0 0 20 20"><path d="M4.2 5.8a1.6 1.6 0 0 1 1.6-1.6h8.4a1.6 1.6 0 0 1 1.6 1.6v5.6a1.6 1.6 0 0 1-1.6 1.6H9.4l-3.4 2.8V13h-.2a1.6 1.6 0 0 1-1.6-1.6Z"></path></svg><b data-chipcount>1</b></span>
<span class="doc__state" data-state>Saved</span>
</header>
<div class="doc__body" data-body>
<h1 class="doc__title">What’s new in 3.2</h1>
<p class="doc__p" data-text>We rebuilt the editor from the ground up. <span data-target>Every draft now syncs across your devices in under a second,</span> even on a slow train connection.</p>
<p class="doc__p doc__p--soft" data-text>Comments stay pinned to the words they talk about, and the outline follows you as you write.</p>
<p class="doc__meta"><span data-count>0</span> words · 1 min read</p>
<div class="marks" data-marks aria-hidden="true"></div>
</div>
<div class="bar" data-bar role="toolbar" aria-label="Format selection">
<div class="bar__shell" data-shell>
<div class="bar__tools" data-tools>
<button class="tool" type="button" data-act="bold" aria-label="Bold" aria-pressed="false">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M6.2 4.2h4.6a3 3 0 0 1 0 6H6.2Zm0 6h5.4a3.1 3.1 0 0 1 0 6.2H6.2Z"></path></svg>
</button>
<button class="tool" type="button" data-act="italic" aria-label="Italic" aria-pressed="false">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M8.6 4.2h6M5.4 15.8h6M11.8 4.2 8.2 15.8"></path></svg>
</button>
<button class="tool" type="button" data-act="link" aria-label="Link">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M8.4 11.6a3 3 0 0 0 4.3 0l2.6-2.6a3 3 0 0 0-4.3-4.3l-.9.9"></path><path d="M11.6 8.4a3 3 0 0 0-4.3 0L4.7 11a3 3 0 0 0 4.3 4.3l.9-.9"></path></svg>
</button>
<button class="tool" type="button" data-act="comment" aria-label="Comment">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4.2 5.8a1.6 1.6 0 0 1 1.6-1.6h8.4a1.6 1.6 0 0 1 1.6 1.6v5.6a1.6 1.6 0 0 1-1.6 1.6H9.4l-3.4 2.8V13h-.2a1.6 1.6 0 0 1-1.6-1.6Z"></path></svg>
</button>
<span class="bar__div" aria-hidden="true"></span>
<button class="tool tool--ai" type="button" data-act="ai" aria-label="Ask AI" aria-expanded="false">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 3.4c.5 3.3 1.9 4.9 5.2 5.4-3.3.5-4.7 2.1-5.2 5.4-.5-3.3-1.9-4.9-5.2-5.4 3.3-.5 4.7-2.1 5.2-5.4Z"></path><path d="M15.2 13.4c.2 1.3.8 1.9 2 2.1-1.2.2-1.8.8-2 2.1-.2-1.3-.8-1.9-2-2.1 1.2-.2 1.8-.8 2-2.1Z"></path></svg>
<span>Ask AI</span>
</button>
</div>
<form class="bar__link" data-linkform autocomplete="off">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M8.4 11.6a3 3 0 0 0 4.3 0l2.6-2.6a3 3 0 0 0-4.3-4.3l-.9.9"></path><path d="M11.6 8.4a3 3 0 0 0-4.3 0L4.7 11a3 3 0 0 0 4.3 4.3l.9-.9"></path></svg>
<label class="bar__label" for="url">Link address</label>
<input class="bar__field" id="url" type="text" data-url placeholder="Paste a link" spellcheck="false">
<button class="bar__ok" type="submit" aria-label="Apply link">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4.8 10.4 8.3 13.8 15.2 6.4"></path></svg>
</button>
</form>
</div>
<span class="bar__nib" data-nib aria-hidden="true"></span>
</div>
<div class="menu" data-menu role="menu" aria-label="Ask AI">
<button class="menu__item" type="button" role="menuitem" data-ai="improve">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4.4 15.6 12.8 7.2M11.2 5.6l3.2 3.2M15 3.6v2.2M16.1 4.7h-2.2M5.6 4.2v1.8M6.5 5.1H4.7"></path></svg>
<span>Improve writing</span>
</button>
<button class="menu__item" type="button" role="menuitem" data-ai="shorten">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 6.5h12M4 10h8M4 13.5h5"></path></svg>
<span>Make shorter</span>
</button>
<button class="menu__item" type="button" role="menuitem" data-ai="translate">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M3.8 5.2h7M7.3 3.6v1.6M9.4 5.2c-.6 2.8-2.4 5-5 6.2M5.8 7.4c.8 1.6 2.2 2.9 4 3.7M10.6 16.4l2.7-6.6 2.7 6.6M11.6 14.2h3.4"></path></svg>
<span>Translate to Italian</span>
</button>
</div>
</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"></path></svg>
<svg class="caret" data-caret viewBox="0 0 12 24" aria-hidden="true"><path d="M3 2.5h6M3 21.5h6M6 2.5v19"></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.
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 “Selection toolbar” from Animorio and fit it into my siteAt start the paragraphs are split into words, each in an inline-block span, with the spaces left as text so lines wrap as before. That way GSAP can give every word its own weight and slant, and the selection is measured word by word.
The browser’s own is made transparent with ::selection: in its place there are rounded rectangles, one per line, built by joining the rectangles of the selected words that sit at the same height. As the selection grows, the last line’s rectangle stretches with a short tween; when a word changes weight it is redrawn on every frame.
The toolbar sits above the first line, centred, and stays inside the document; if there is no room above it goes under the last line and its tip flips. It is born with back.out from a little lower and a little smaller, with the scale origin on the tip; when the selection changes it glides there on a calmer spring.
The icons and the link field are two layers in the same pill: on click the icons slide away, the field comes in and the pill goes from the icons’ width to the field’s with back.out, while the toolbar re-centres and the tip stays on the sentence.
Ask AI replaces the selected words with new ones; a tween from zero to one uncovers the letters from the left, and ahead of the uncovered point nine random letters change on every frame. At the end the words go from violet to the text colour, the status says Saving and the word count rolls to the new number.
| Name | File | Default | What it changes |
|---|---|---|---|
LINK | script.js | quillary.app/sync | The address the autopilot types into the link field. |
SHORTER | script.js | Drafts now sync in under a second, | The sentence rewritten by Make shorter. |
IMPROVED | script.js | Every draft now reaches all your devices in less than a second, | The sentence rewritten by Improve writing. |
ITALIAN | script.js | Ogni bozza ora si sincronizza sui tuoi dispositivi in meno di un secondo, | The sentence rewritten by Translate to Italian. |
ACCENT | script.js | #5b5bd6 | The colour of the selection, the links and the confirm button. |
BOLD_WEIGHT | script.js | 680 | The weight of bold words, on the wght axis of Mona Sans. |
SPRING | script.js | 1 | How much the toolbar bounces when it appears and moves. |
PACE | script.js | 1 | The speed of the autopilot. |
For the editor of a notes or writing app, a CMS panel, comments on a shared document, a blog with an in-browser editor, any text you select to change it or ask the AI about it.
The document narrows to the box and the text is sized on height too; the toolbar stays inside the document edges and, if there is no room above the sentence, goes underneath. The link field gets shorter under 440 pixels. With touch, the phone’s own selection brings up the toolbar just like the mouse.
No springs or movement: the toolbar and the menu fade in where they belong, bold and italic change at once, the new sentence arrives with a fade instead of random letters and the drawn pointer is not shown.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 11 KB; the libraries: GSAP 28 KB.
Tested on 26 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.