Skip to content
animorio
IT
All components

Passcode keypad

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

The lock screen of a bank app, on very light grey, in the style of real product interface pieces: ten round keys that really press down with a light ripple, four dashes that fill from the bottom instead of the usual dots. A wrong passcode shakes the dashes in red and drains them from the last; the right one slides them together into the body of a padlock, the shackle draws itself on top, clicks, springs open and turns green: «Welcome back».

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>
<!--
  "Passcode keypad" 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 passcode keypad that unlocks the app</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 lock screen of an invented bank app: ten round keys that really press down with a light ripple, four dashes
         that fill from the bottom, a wrong passcode that shakes and drains them, and the right one that pulls the four
         dashes together into the body of a padlock whose shackle draws itself and springs open -->
    <section class="pad" data-pad aria-labelledby="titolo">
      <header class="pad__head">
        <svg class="pad__mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 18.5h16M5.5 18.5V10M18.5 18.5V10M9.5 18.5V10M14.5 18.5V10M3.5 9.2 12 4.5l8.5 4.7Z"></path></svg>
        <p class="pad__brand">Marlbank</p>
      </header>

      <div class="pad__titles">
        <h1 class="pad__title" id="titolo"><span class="roll" data-title>Enter your passcode</span></h1>
        <p class="pad__sub" aria-live="polite"><span class="roll" data-sub>Personal account · Elin</span></p>
      </div>

      <svg class="code" data-code viewBox="0 -8 136 54" role="img" aria-label="Passcode, 0 of 4 digits">
        <g data-dashes>
          <g class="dash" data-dash="0"><rect class="dash__track" x="2" y="26" width="26" height="12" rx="6"></rect><rect class="dash__fill" data-fill x="2" y="26" width="26" height="12" rx="6"></rect></g>
          <g class="dash" data-dash="1"><rect class="dash__track" x="38" y="26" width="26" height="12" rx="6"></rect><rect class="dash__fill" data-fill x="38" y="26" width="26" height="12" rx="6"></rect></g>
          <g class="dash" data-dash="2"><rect class="dash__track" x="74" y="26" width="26" height="12" rx="6"></rect><rect class="dash__fill" data-fill x="74" y="26" width="26" height="12" rx="6"></rect></g>
          <g class="dash" data-dash="3"><rect class="dash__track" x="110" y="26" width="26" height="12" rx="6"></rect><rect class="dash__fill" data-fill x="110" y="26" width="26" height="12" rx="6"></rect></g>
        </g>
        <g class="lock" data-lock>
          <path class="lock__shackle" data-shackle d="M57 24V15.5a11 11 0 0 1 22 0V24"></path>
          <rect class="lock__body" data-body x="48" y="23" width="40" height="21" rx="6.5"></rect>
          <path class="lock__hole" data-hole d="M68 31.5v4.5"></path>
        </g>
      </svg>

      <p class="pad__msg" data-msg aria-live="assertive"></p>

      <div class="keys" data-keys>
        <button class="key" type="button" data-key="1"><span class="key__face"><b>1</b><i>&nbsp;</i></span></button>
        <button class="key" type="button" data-key="2"><span class="key__face"><b>2</b><i>ABC</i></span></button>
        <button class="key" type="button" data-key="3"><span class="key__face"><b>3</b><i>DEF</i></span></button>
        <button class="key" type="button" data-key="4"><span class="key__face"><b>4</b><i>GHI</i></span></button>
        <button class="key" type="button" data-key="5"><span class="key__face"><b>5</b><i>JKL</i></span></button>
        <button class="key" type="button" data-key="6"><span class="key__face"><b>6</b><i>MNO</i></span></button>
        <button class="key" type="button" data-key="7"><span class="key__face"><b>7</b><i>PQRS</i></span></button>
        <button class="key" type="button" data-key="8"><span class="key__face"><b>8</b><i>TUV</i></span></button>
        <button class="key" type="button" data-key="9"><span class="key__face"><b>9</b><i>WXYZ</i></span></button>
        <button class="key key--text" type="button" data-forgot>Forgot?</button>
        <button class="key" type="button" data-key="0"><span class="key__face"><b>0</b><i>&nbsp;</i></span></button>
        <button class="key key--text" type="button" data-del aria-label="Delete">
          <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 5.5h10a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H9L3 12Z"></path><path d="m11.5 9.5 5 5M16.5 9.5l-5 5"></path></svg>
        </button>
      </div>
    </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.

41 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 “Passcode keypad” 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 very light grey sits the white panel of Marlbank, an invented bank: the mark, «Enter your passcode», the line «Personal account · Elin», four rounded grey dashes and underneath a phone keypad, ten round keys with the digit and the small letters, «Forgot?» and the delete key. Pressed, a key goes down and darkens slightly, a light ripple opens from where you touched it, and released it comes back up on a small spring. Every digit fills a dash from the bottom with a bounce and nudges the dash up a hair. A wrong passcode turns the four dashes red, shakes them with a damped wobble, «Wrong passcode. 2 tries left» appears underneath and the dashes drain from the last. The right passcode slides the four dashes towards the centre until they become one, which swells into the body of a padlock with its keyhole; the shackle draws itself on top, the padlock gives a click, the shackle lifts, swings and opens, everything turns green, the title rolls to «Welcome back, Elin» and the keypad dims. A drawn pointer gets it wrong once, then types the right passcode with a wrong digit it deletes, and starts again; it also really works, with a finger, the mouse and the keyboard (digits, backspace, Esc to lock again).

How it works

Keys that really press

Every key has a face separate from the button: on pointerdown GSAP takes it to a slightly smaller scale and one pixel down in 0.08 s, and on release it comes back with back.out. Two ripples, a dark one and a light one in soft-light, start from the touch point and grow as they fade.

Dashes that fill from the bottom

The dashes are SVG rectangles with a grey track and a fill on top, scaled vertically from the bottom: back.out takes it just past full and the dash jumps 2 units and comes back on a spring.

The error wobble

The dash group runs a set of x keyframes with a shrinking amplitude (1, 0.85, 0.6, 0.38, 0.18), then the fills drain from the last with a reversed stagger.

From dashes to padlock

Each dash slides to the centre of the row by its own distance; when they overlap the padlock lights up, its body starting at the size of a dash and growing with back.out on the x, y, width and height attributes. The shackle is a path drawn with strokeDashoffset, then it lifts and swings around its left leg with svgOrigin.

The autopilot

A timeline with repeatRefresh takes the drawn pointer to the keys reading their real positions each time and presses with the same functions as a finger. At the first real touch it stops, and starts again after eight quiet seconds.

Values to change

NameFileDefaultWhat it changes
PINscript.js2580The right passcode that unlocks the app, four digits.
ACCENTscript.js#111113The colour of the filled dashes and of the closed padlock.
OPEN_COLORscript.js#1f9d55The colour of the padlock as it opens.
PRESSscript.js0.9How far a pressed key goes down (1 = not at all).
SHAKEscript.js9How many pixels the dashes shake with a wrong passcode.
PAUSEscript.js1The seconds the autopilot waits between one gesture and the next.

Try them in the Playground

When to use it

For the lock screen of a banking, payments or health app, the second step of a sign-in, the confirmation of a transfer, or anywhere a short code is asked for with a keypad.

On phones

The keys are sized from both the width and the height of the screen, between 38 and 62 pixels, so the whole keypad fits even the phone’s short preview box; below 460 pixels of height the small letters on the keys go away. The ripple starts where the finger lands.

With reduced motion

The padlock is already open and green, with the welcome and the keypad dimmed: no ripples, shakes or slides; Esc or a tap on the padlock locks it again, and digits appear without motion.

Pitfalls

  • The dash fill scaled vertically needs transformOrigin 50% 100% set once by GSAP: on SVG the percentage is taken from the rectangle’s own box, not the page.
  • The padlock shackle has to swing around its left leg even after lifting: with svgOrigin the point stays in SVG coordinates and the swing does not drift.
  • The error wobble goes on the dash group, not on each dash: each dash’s x is needed later to slide it into the padlock and would be overwritten.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 28 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