Skip to content
animorio
IT
All components

Date of birth field

Forms, HoverGSAP, CSS onlyMediumCompressed weight: Demo 8.3 KBGSAP 28 KBFreeDownload the zip

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.

The code

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>

Playground

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

Or ask your AI assistant for it

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 site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On white sits the card of Juniply, an invented app, at the sign-up step that asks for the date of birth: the mark, the title «When’s your birthday?», the line «We only use it to keep your account safe.», the Date of birth label and a grey field with DD / MM / YYYY in light grey and the calendar icon on the right. Tapped, the field turns white with a violet border, a light violet pill settles on the day part and the caret appears. Digits rise from below with a small stretch and settle; once the day is done the pill slides to the month on a spring that goes just past it, then to the year. Under the field the date spells itself out in words: the day number, then the month name rising from its mask, then the year. A 4 as the first digit of the day (or a 2 as the first of the month) takes its leading zero by itself, sliding in from the side. If the date does not exist, like 31 February, the day turns red and shakes, the border goes red and the warning «February only has 29 days» rises in place of the date with its drawn triangle; tapping the day drops its digits so it can be typed again. With the whole date the calendar icon spins away, a circle and a green check draw themselves in its place, the age pill rises on the right with its number counting up to the real years, and the Continue button fills with black from the left, its arrow giving a nudge. A drawn pointer does it all by itself, gets the day wrong, fixes it, presses Continue and starts again; it also really works, with the keyboard, the phone’s number pad and by pasting a date.

How it works

A real field, three drawn parts

Over 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 that follows

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).

A date that checks itself

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.

An ending that lights up

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.

The autopilot

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.

Values to change

NameFileDefaultWhat it changes
BIRTHDAYscript.js14/02/1996The date the autopilot types, day/month/year.
MIN_AGEscript.js13The minimum age to create the account.
ACCENTscript.js#5b47e0The colour of the pill following the active part and of the caret.
TYPE_SPEEDscript.js0.17The seconds between one digit and the next for the autopilot.
SPRINGscript.js1.6How far the pill goes past the new part before settling.
PAUSEscript.js1The seconds the autopilot waits between one gesture and the next.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • Three separate inputs jumped focus on iPhone at every part, and the keyboard closed and reopened: a single input, transparent over the drawing, keeps the keyboard open from start to finish.
  • The 29 February check has to run again when the year arrives: before the year February has 29 days, then 28 if the year is not a leap year, and the error must be able to appear at the very last digit.
  • Measuring the parts before Mona Sans had loaded put the pill a few pixels off: the first measurement waits for document.fonts.ready and resize puts everything back in place.

Libraries

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.

Testing

Tested on 27 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

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.

All components