Skip to content
animorio
IT
All components

Bank verification code field

Forms, Transitions, SVGGSAP, CSS onlyMediumCompressed weight: Demo 9.6 KBGSAP 28 KBFreeDownload the zip

The six-digit verification code field (OTP) of a banking app, on black, in a minimal premium style: the code that arrived in Messages is pasted with one tap and the digits fall into the cells in a cascade, landing a pixel low; while it is checked a light runs along the cell edges, then the cells zip shut from the sides into a green pill with a tick. A wrong code shakes them on a spring and empties them from the right.

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>
<!--
  "Bank verification code 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 bank verification code with the falling digits</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 one-time code of a banking app: a code from Messages is pasted and its digits fall into the cells one
         after the other, a light runs along the cell edges while it is checked, then the cells zip shut into a green
         pill with a tick; a wrong code shakes the cells on a spring and empties them from the right -->
    <section class="otp" data-otp aria-labelledby="otp-title">
      <span class="otp__glow" aria-hidden="true" data-glow></span>
      <header class="otp__head">
        <span class="otp__mark" aria-hidden="true">
          <svg viewBox="0 0 24 24"><path d="M12 3.2l7 2.7v5.4c0 4.3-2.9 7.9-7 9.5-4.1-1.6-7-5.2-7-9.5V5.9z"/><path d="M9.2 11.6V10a2.8 2.8 0 015.6 0v1.6"/><rect x="8.2" y="11.6" width="7.6" height="5" rx="1.4"/></svg>
        </span>
        <div class="otp__words">
          <h1 class="otp__title" id="otp-title"><span data-title>Confirm your transfer</span></h1>
          <p class="otp__sub"><span data-sub>£1,240.00 to Mara Quinn, Halden Bank</span></p>
        </div>
      </header>

      <div class="otp__field" data-field>
        <label class="sr" for="otp-input">Enter the 6-digit code sent to your phone</label>
        <input class="otp__input" id="otp-input" type="text" inputmode="numeric" autocomplete="one-time-code" maxlength="6" spellcheck="false" aria-describedby="otp-status" data-input>
        <div class="otp__cells" aria-hidden="true" data-cells></div>
        <div class="otp__done" aria-hidden="true" data-done>
          <span class="otp__tick"><svg viewBox="0 0 24 24"><path d="M6 12.6l4 4L18.2 8" data-tick/></svg></span>
          <span class="otp__done-words" data-done-words>Transfer approved</span>
        </div>
      </div>

      <p class="otp__status" id="otp-status" role="status" aria-live="polite">
        <span class="otp__status-in" data-status>Code expires in <b data-clock>4:59</b></span>
      </p>

      <button class="otp__suggest is-waiting" type="button" aria-disabled="true" data-suggest>
        <span class="otp__bubble" aria-hidden="true">
          <svg class="otp__spin" viewBox="0 0 24 24"><circle cx="12" cy="12" r="7"/><path d="M12 5a7 7 0 017 7"/></svg>
          <svg class="otp__msg" viewBox="0 0 24 24"><path d="M12 4.5c4.7 0 8.2 3 8.2 6.7s-3.5 6.7-8.2 6.7c-.9 0-1.8-.1-2.6-.3L5.6 19.4l.9-3.3C4.7 14.9 3.8 13.1 3.8 11.2c0-3.7 3.5-6.7 8.2-6.7z"/></svg>
        </span>
        <span class="otp__from"><span data-from>Waiting for the code</span></span>
        <span class="otp__code" data-suggest-code>482 913</span>
      </button>
    </section>

    <!-- the pretend pointer of the automatic preview -->
    <svg class="pointer" viewBox="0 0 24 24" aria-hidden="true" data-pointer><path d="M5.5 3.5l13 7.4-5.6 1.4-2.9 5.3z"/></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.

27 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 “Bank verification code 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 a black background the Confirm your transfer card of a made-up banking app, Halden Bank: a shield with a padlock, £1,240.00 to Mara Quinn and six dark cells in two groups of three, with Code expires in 4:59 below, counting down every second, and a Waiting for the code row with a small spinner. The cell to type in has a light edge and a blinking caret. On its own the demo first types a code with one wrong digit: each digit falls from above into its cell, blurred, goes one pixel too low and comes back up, and the cell squashes a touch. With the last digit a pale green light runs along the edge of every cell, one after the other, the digits breathe and Verifying code shimmers. The code is wrong: the cells turn red, are thrown sideways and come back on a spring, That code didn’t match. Try again. shows below, and the digits rise and vanish from the right. Then the message arrives: the spinner turns into a green bubble and the row reads From Messages with 482 913; a pointer taps it, the digits leave the suggestion and fall into the cells in a cascade, the light runs again, the edges turn green from the left and the cells zip shut from the sides towards the middle into a green pill where a tick draws itself next to Transfer approved. The title becomes Transfer sent, a green glow lights up behind the card; then it all goes back to six empty cells. The code can also be typed by hand, digit by digit, or pasted.

How it works

A real field under the cells

The cells only draw: the real field is a single input, invisible and as big as they are, with inputmode numeric, autocomplete one-time-code and a 16-pixel typeface. Pasting, the number keyboard, screen readers and the code iPhone offers above the keyboard all work by themselves; the script keeps only the digits and compares the new value with the old one, cell by cell.

The falling digits

A new digit starts FALL pixels higher, blurred and stretched upright, and drops with power2.in to one pixel below its place, then comes back up with power2.out; the moment it touches, the cell squashes to scaleY 0.97 and springs back with back.out. A pasted code makes the same fall in a cascade, one digit every CASCADE seconds, while the suggestion's digits rise and fade to the same beat.

The light on the edge

Each cell has an SVG with a rect redrawn at its real size (on resize too) and pathLength 100: the stroke is a dash of 16 out of 84 that goes round with stroke-dashoffset from 8 to -92, looping, each cell 0.07 seconds after the one before, with a drop-shadow for the glow. Meanwhile the digits breathe in opacity and the Verifying code line shimmers with a gradient in the text.

The cells zipping shut

With the right code the edges turn green from the left; then each cell moves to the middle (its x is the distance between its centre and the row's), narrows and fades, with a from edges stagger: the outer ones close first, like a zip. The pill grows from scaleX 0.28 with back.out, the tick's disc bounces and the tick draws itself with stroke-dashoffset.

The wrong code

The cells take the error class, are pushed SPRING pixels in 0.07 seconds and come back with elastic.out(1, 0.22), one just after the other; the field gets aria-invalid and the status line says so. Then the digits rise and vanish from the right, one every 0.08 seconds, and the field is free again.

The demo on its own

Until someone touches it, the demo types a code with the third digit wrong, then a pretend pointer taps the From Messages suggestion. The first real touch (pointerdown or a key) stops the demo, empties the cells and leaves the suggestion ready; all the timing is GSAP, no setTimeout.

Values to change

NameFileDefaultWhat it changes
LENGTHscript.js6How many digits the code has.
CODEscript.js'482913'The right code, the one that arrives in Messages.
FALLscript.js22How many pixels a digit falls before it lands.
CASCADEscript.js0.075The seconds between two pasted digits.
CHECKscript.js1.5The seconds the light runs while the code is checked.
SPRINGscript.js12How many pixels a wrong code throws the cells sideways.
HOLDscript.js2.6The seconds the green pill stays before the card starts over.

Try them in the Playground

When to use it

For confirming a transfer or a payment, two-factor verification, signing in to a banking or payments app, confirming a phone number: wherever a code of a few digits arrives by text message.

On phones

The card is at most the screen width minus 28 pixels and the cells are measured on width and height (min of vw and vh), so they fit the phone's preview box too. A tap opens the number keyboard and on iPhone the code that came by text message is offered above the keyboard; the 16-pixel typeface stops the page zooming in.

With reduced motion

The digits fade in and out without falling, the light does not run but the edges glow on and off slowly, the wrong cells turn red without shaking, the green pill fades in with the tick already drawn and the pretend pointer does not move.

Pitfalls

  • The light's outline cannot live in an SVG with preserveAspectRatio none: corners and stroke would stretch. The rect is redrawn in pixels at each cell's real size, on load, when the fonts arrive and on every resize.
  • The digit's fall and the cell's squash are on two different elements: the cell takes y and scaleY when the digit lands, the digit its fall; together on one element the two springs would cancel each other.
  • The green pill is centred with the CSS translate property while GSAP scales it: a translate(-50%) written inside transform would be wiped out by GSAP's transform.
  • While the code is checked the field is readOnly and every change is put back: a digit deleted halfway through the check would leave the cells and the field different.
  • The pretend pointer and the typing on its own stop at the first real pointerdown (isTrusted): otherwise the demo would keep typing over the digits of whoever is trying it.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 9.6 KB; the libraries: GSAP 28 KB.

Testing

Tested on 12 November 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