
The elastic button
Buttons, Hover, Text
A text field with one gesture, as simple as the seal logo: tapping it, the label rises onto the border, shrinks and takes weight, and the top line opens for it from the middle, its two ends passing their mark by a pixel and settling. Left empty, the label drops back and the border closes behind it.
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>
<!--
"Floating label field" 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 field whose label settles into the border</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>
<!-- one text field: on focus the label rises and the top border opens for it from the middle outwards -->
<div class="field" data-field>
<svg class="field__line" data-svg aria-hidden="true"><path data-border /></svg>
<label class="field__label" for="email" data-label><span data-label-text>Email</span></label>
<input class="field__input" id="email" type="email" autocomplete="off" spellcheck="false" data-input data-autoclic>
<p class="field__help" data-help>Only for your receipts.</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.
14 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 “Floating label field” from Animorio and fit it into my siteThe outline is an SVG path that starts at one side of the gap, runs all the way round with rounded corners and ends at the other side. The gap is centred on the centre of the label once it has settled (measured once at its final weight and width, then shrunk) and widens with the gap value from 0 to 1: on every frame the path is rewritten with its two ends in the right place.
How far the label has risen, how open the gap is and how much accent is on sit in one object GSAP animates. The label rises by half the height and goes from 17 to 12 pixels with a scale, from weight 400 to 560 and width 100 to 112 on Mona Sans’s axes; the gap starts a moment later, so it seems to open for it. Both with back.out: the extra pixel and the settle are BOUNCE.
On leaving, if the field is empty, the label drops back and the gap closes a moment later, the two ends meeting with the same spring; if it is filled, the label stays in the border and only turns grey. The colour of the line and the label comes from gsap.utils.interpolate between the colours in :root.
Until someone touches it, a GSAP timeline opens the field, types EXAMPLE one letter at a time with a drawn caret (measured on a hidden twin of the text), deletes it and closes it, without ever taking the real focus. The first real touch stops it and the field goes back to being a field.
| Name | File | Default | What it changes |
|---|---|---|---|
LABEL | script.js | 'Email' | The label of the field. |
EXAMPLE | script.js | 'ada@harlow.studio' | What the preview types on its own. |
HELP | script.js | 'Only for your receipts.' | The line under the field while it is in use ('' = none). |
LIFT | script.js | 0.5 | How long the label takes to rise, in seconds. |
OPEN | script.js | 0.55 | How long the border takes to open, in seconds. |
BOUNCE | script.js | 1.6 | How far the label and the ends pass their mark: 0 none, 3 a lot. |
AUTO | script.js | true | The preview types and clears on its own until someone touches it. |
--accento | style.css | #e8590c | The colour of the field in use. |
For any form that wants a clean field with the label always in sight: sign-ups, log-ins, payments, contact forms. The border opening tells you where you are without adding anything.
The field widens to 86% of the screen (at most 340 pixels) and the gap is measured again whenever the size changes; the rest is the same.
The label and the border change state without motion, the help line fades in and the preview does not type on its own.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 4.2 KB; the libraries: GSAP 28 KB.
Tested on 30 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.