
The elastic button
Buttons, Hover, Text
The «When’s your birthday?» step of an app’s sign-up, on white, in the style of real product interface pieces: a single field split into day, month and year. A violet pill slides on a spring to the part being typed, digits roll up into place, a 5 in the day takes its leading zero by itself, and under the field the date spells itself out with the month rising from its mask. A 31 February shakes the day in red with the warning; the right date draws the check, brings up the age and fills the Continue button with black.
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>
<!--
"Date of birth 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 date of birth field that steps from day to month to year</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>
<!-- the sign-up step of an invented app: a date of birth field split into day, month and year. The highlight slides from
segment to segment on a spring, digits roll in, a single digit that can only be one thing gets its zero for free,
the month spells itself under the field, an impossible date shakes the day, and a complete date lights the check,
the age and the Continue button -->
<section class="card" data-card aria-labelledby="titolo">
<header class="card__head">
<svg class="card__mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3.5c3.6 2.6 5.4 5.5 5.4 8.6a5.4 5.4 0 0 1-10.8 0c0-3.1 1.8-6 5.4-8.6Z"></path><path d="M12 9.5v11"></path></svg>
<p class="card__brand">Juniply <span>/ Create account</span></p>
</header>
<h1 class="card__title" id="titolo">When’s your birthday?</h1>
<p class="card__sub">We only use it to keep your account safe.</p>
<label class="card__label" for="entrata">Date of birth</label>
<div class="field" data-field>
<input class="field__input" id="entrata" data-input type="text" inputmode="numeric" autocomplete="bday" aria-describedby="aiuto" maxlength="10">
<span class="field__pill" data-pill aria-hidden="true"></span>
<div class="field__segs" aria-hidden="true">
<span class="seg" data-seg="0"><span class="slot" data-slot>D</span><span class="slot" data-slot>D</span></span>
<span class="sep" data-sep>/</span>
<span class="seg" data-seg="1"><span class="slot" data-slot>M</span><span class="slot" data-slot>M</span></span>
<span class="sep" data-sep>/</span>
<span class="seg seg--year" data-seg="2"><span class="slot" data-slot>Y</span><span class="slot" data-slot>Y</span><span class="slot" data-slot>Y</span><span class="slot" data-slot>Y</span></span>
</div>
<span class="field__caret" data-caret aria-hidden="true"></span>
<svg class="field__icon" data-cal viewBox="0 0 24 24" aria-hidden="true"><rect x="4" y="5.5" width="16" height="14" rx="3"></rect><path d="M4 10h16M8.5 3.5v4M15.5 3.5v4"></path></svg>
<svg class="field__icon field__icon--ok" data-ok viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9" data-ok-ring></circle><path d="m8 12.3 2.7 2.7L16.2 9.4" data-ok-tick></path></svg>
</div>
<div class="hint" id="aiuto" aria-live="polite">
<p class="hint__line hint__line--date" data-date><span data-date-day></span><span class="mask"><span data-date-month></span></span><span data-date-year></span></p>
<p class="hint__line hint__line--err" data-err>
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4 21 19.5H3Z"></path><path d="M12 10v4.2M12 16.9v.2"></path></svg>
<span data-err-text></span>
</p>
<p class="hint__age" data-age><span class="roll" data-age-num>0</span> years old</p>
</div>
<button class="go" type="button" data-go disabled>
<span class="go__fill" data-go-fill></span>
<span class="go__label" data-go-label>Continue</span>
<svg class="go__arrow" data-go-arrow viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h13M13 6.5 18.5 12 13 17.5"></path></svg>
</button>
</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>
</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.
33 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 “Date of birth field” from Animorio and fit it into my siteOver the field sits a transparent input with inputmode numeric, so the phone opens its number pad; beforeinput stops the browser’s own text and passes every digit (a pasted date too) to a function that fills eight boxes. The three parts are just drawing: fixed-width spans, so digits never shift anything.
The pill is a single element behind the digits: on every change the active part is measured with getBoundingClientRect against the field and GSAP takes x and width there with back.out, going just past and back. The caret does the same on the box to type and blinks with steps(1).
As soon as day and month are there the days of the month are checked (29 for February until the year arrives, then 28 or 29 by year); the year has to be between 1900 and today and the age above the minimum. The error colours and shakes only the wrong part with damped keyframes.
A timeline spins the calendar away, draws the circle and the check with strokeDashoffset, brings up the age pill with its number counted by a tween and fills the button with a black background in scaleX from the left.
A timeline with repeatRefresh takes the drawn pointer to the field reading real positions each time, types with the same functions as the keyboard, gets the day wrong on purpose and fixes it. At the first real touch it stops, and starts again after eight quiet seconds.
| Name | File | Default | What it changes |
|---|---|---|---|
BIRTHDAY | script.js | 14/02/1996 | The date the autopilot types, day/month/year. |
MIN_AGE | script.js | 13 | The minimum age to create the account. |
ACCENT | script.js | #5b47e0 | The colour of the pill following the active part and of the caret. |
TYPE_SPEED | script.js | 0.17 | The seconds between one digit and the next for the autopilot. |
SPRING | script.js | 1.6 | How far the pill goes past the new part before settling. |
PAUSE | script.js | 1 | The seconds the autopilot waits between one gesture and the next. |
For the sign-up of an app or a bank, the profile of an age-restricted service, a booking that asks for a traveller’s date of birth, any form where a date is quicker to type than to pick from a calendar.
The card takes the full width minus the margins, the vertical gaps tighten with the screen height and the field stays 50 pixels tall, easy for a finger; a tap opens the number pad and a tap on a part already typed empties it to type it again.
The date is already typed and checked: the check drawn, the age and the full button, with no sliding pill, rolling digits or shakes; when typing, digits fade in and the drawn pointer stays hidden.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 8.3 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.