
The elastic button
Buttons, Hover, Text
One picker, one gesture, in the clean style of interface pieces for AI apps: the «Response length» card with three choices, Concise, Balanced and Detailed. On a choice the dark pill glides onto the word and the draft reply below, made of grey lines, grows or shrinks: the new lines are written one after the other by a thin violet caret that lands a pixel too far and settles, the extra ones are taken back from the bottom, the card closes on a spring and the word count rolls.
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>
<!--
"Response length picker" 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 response length picker with the lines that grow longer</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">
<!-- one gesture: pick how long the assistant should answer, and the draft reply below grows or shrinks to it -->
<section class="len" data-len aria-labelledby="len-title">
<header class="len__head">
<span class="len__title" id="len-title">Response length</span>
<span class="len__count" aria-live="polite"><span class="len__tilde">about</span> <span data-count>120</span> words</span>
</header>
<div class="len__seg" role="radiogroup" aria-labelledby="len-title" data-seg>
<span class="len__pill" data-pill aria-hidden="true"></span>
<button class="len__opt" type="button" role="radio" aria-checked="false" tabindex="-1" data-opt><span>Concise</span></button>
<button class="len__opt" type="button" role="radio" aria-checked="true" tabindex="0" data-opt><span>Balanced</span></button>
<button class="len__opt" type="button" role="radio" aria-checked="false" tabindex="-1" data-opt><span>Detailed</span></button>
</div>
<div class="len__preview" data-preview aria-hidden="true">
<span class="len__line" data-line></span>
<span class="len__line" data-line></span>
<span class="len__line" data-line></span>
<span class="len__line" data-line></span>
<span class="len__line" data-line></span>
<span class="len__line" data-line></span>
<span class="len__caret" data-caret></span>
</div>
</section>
</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.
28 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 “Response length picker” from Animorio and fit it into my siteEach length is a list of widths in percent (Concise has two lines, Balanced four, Detailed six): GSAP takes every line to its own, so the draft stays right at any card width with no recalculation.
On every frame of the timeline the caret looks for the last line that has ink and puts itself at its end: it has no tween of its own, it follows the lines, even when they retract. The new lines are written in a row with sine.inOut, each in a time proportional to its length.
The draft’s height goes to that of the coming line 80 milliseconds before the caret starts it, with back.out: the card opens and the line comes into a space already there. When shortening, the lines leave from the bottom and the height drops once the last one is gone.
At the end of the writing the caret gets an extra 1.2 pixel shift that goes back to zero on an elastic spring; the pill arrives with back.out and a sheen made with a CSS variable (--sheen-x) runs once over the finished lines.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #6a4cff | The colour of the caret that writes the lines. |
LABEL_SHORT | script.js | Concise | The first option. |
LABEL_MID | script.js | Balanced | The middle option. |
LABEL_LONG | script.js | Detailed | The last option. |
WORDS_SHORT | script.js | 40 | About how many words a concise reply has. |
WORDS_MID | script.js | 120 | About how many words a balanced reply has. |
WORDS_LONG | script.js | 280 | About how many words a detailed reply has. |
WRITE | script.js | 1 | How fast the caret writes a new line: 2 twice as fast, 0.5 half. |
SPRING | script.js | 1 | How springy the pill and the card are: 0.4 calm, 2 very bouncy. |
SPEED | script.js | 1 | The speed of everything: 2 twice as fast, 0.5 half. |
HOLD | script.js | 2.4 | How many seconds each length stays when the card changes by itself. |
AUTO | script.js | true | The card changes length by itself until someone touches it. |
In the settings of an AI assistant, in a chat composer or in a tool that summarises texts: whoever chooses sees at once how long the answer will be, before asking for it.
On the phone the card takes the screen width minus the margins and the lines stay in percent; the inner padding is also measured on the height. There is no hover, everything else is the same.
The draft fades out and comes back already at the new length, with no lines being written and no springs; the pill and the number take their place at once.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 5.3 KB; the libraries: GSAP 28 KB.
Tested on 31 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.