
The elastic button
Buttons, Hover, Text
A payment form on white with the card drawn above it: the digits of the number rise onto the card one by one in groups of four, the name and the expiry date write themselves as you type and a frame of light moves onto the part you are filling in. On the security code the card turns over to show its back, a wrong field shakes and turns red, and the Pay button lights up only when everything is right.
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>
<!--
"Flipping card form" 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 card form that flips</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">
<!-- a payment form on white: the card on top writes itself while you type, and turns over when the cursor reaches the
security code -->
<section class="pay" data-pay aria-label="Card payment">
<div class="scene" data-scene>
<div class="card" data-card>
<div class="face face--front" data-front>
<span class="glare" data-glare aria-hidden="true"></span>
<div class="front__top">
<span class="bank" data-bank>Tarnley</span>
<svg class="wave" viewBox="0 0 24 24" aria-hidden="true"><path d="M8.5 7.5a6.5 6.5 0 0 1 0 9M12 5a10 10 0 0 1 0 14M15.5 2.8a13 13 0 0 1 0 18.4"></path></svg>
</div>
<span class="chip" aria-hidden="true"><i></i><i></i><i></i></span>
<div class="num" data-num aria-hidden="true"></div>
<div class="front__bottom">
<div class="field-on-card" data-on="name">
<span class="tiny">Card holder</span>
<span class="holder" data-holder>Your name</span>
</div>
<div class="field-on-card" data-on="exp">
<span class="tiny">Expires</span>
<span class="exp" data-exp aria-hidden="true"></span>
</div>
<svg class="mark" viewBox="0 0 40 24" aria-hidden="true"><path d="M6 20 13 4h4L10 20Z"></path><path d="M15 20 22 4h4l-7 16Z"></path><path d="M24 20 31 4h4l-7 16Z"></path></svg>
</div>
</div>
<div class="face face--back" data-back>
<span class="band" aria-hidden="true"></span>
<div class="sign">
<span class="sign__strip" aria-hidden="true"></span>
<span class="cvc" data-cvcshow aria-hidden="true"></span>
</div>
<p class="back__note">This card belongs to Tarnley. If found, please return it to any branch.</p>
</div>
<span class="focusbox" data-focusbox aria-hidden="true"></span>
</div>
<span class="shadow" data-shadow aria-hidden="true"></span>
</div>
<form class="form" data-form novalidate autocomplete="off">
<label class="in in--wide" data-box="num">
<span class="in__label" data-label>Card number</span>
<input data-in="num" inputmode="numeric" maxlength="19" spellcheck="false" aria-label="Card number">
</label>
<label class="in in--wide" data-box="name">
<span class="in__label" data-label>Name on card</span>
<input data-in="name" maxlength="24" spellcheck="false" aria-label="Name on card">
</label>
<div class="row">
<label class="in" data-box="exp">
<span class="in__label" data-label>Expiry</span>
<input data-in="exp" inputmode="numeric" maxlength="5" placeholder="MM/YY" aria-label="Expiry date">
</label>
<label class="in in--cvc" data-box="cvc">
<span class="in__label" data-label>CVC</span>
<input data-in="cvc" inputmode="numeric" maxlength="3" aria-label="Security code">
</label>
<button class="paybtn" type="submit" data-paybtn disabled>
<span class="paybtn__fill" data-fill aria-hidden="true"></span>
<svg class="paybtn__ring" data-ring viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="7"></circle></svg>
<svg class="paybtn__check" data-check viewBox="0 0 20 20" aria-hidden="true"><path d="M4.8 10.4 8.4 14l6.8-7.6" pathLength="1"></path></svg>
<span class="paybtn__label" data-paylabel>Pay</span>
</button>
</div>
</form>
</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.
31 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 “Flipping card form” from Animorio and fit it into my siteThe card is an element with transform-style preserve-3d and two faces with backface-visibility hidden, the back already turned by 180 degrees. GSAP does not animate the card directly: it moves an object holding flip, tilt and lift, and on every ticker frame they are combined into one transform, so the CVC flip and the tilt towards the pointer never cancel each other out.
Each place of the number is a small window with overflow hidden, holding a grey dash and the digit. When a digit arrives it comes in from below with back.out while the dash drops and fades; deleting it plays the move in reverse. The number is formatted in groups of four both in the field and on the card.
A thin frame sits over the card and, at every change of field, GSAP takes it on a short spring to the position and size of the right part, number, name or expiry, read with offsetLeft and offsetWidth. On resize it goes back into place, because the card changes size with the box.
The number has to pass the Luhn check, the expiry needs a real month and must not be in the past, the CVC wants three digits. A wrong field, when you leave it, shakes on a timeline of dampening moves and turns red with the reason written in place of its label; the button lights up only when all four fields are right.
A drawn pointer clicks the fields and types, pausing between one group of four digits and the next, gets the expiry wrong on purpose, fixes it, goes to the CVC and pays; it all sits on one timeline that pauses while the payment runs. As soon as the page is really touched the autopilot stops and the form answers whoever is using it.
| Name | File | Default | What it changes |
|---|---|---|---|
BANK | script.js | "Tarnley" | The name of the invented bank written on the card. |
HOLDER | script.js | "Lior Brandt" | The name the autopilot types. |
FLIP_TIME | script.js | 0.8 | The seconds the card takes to turn over. |
TYPE_SPEED | script.js | 1 | How fast the autopilot types. |
DIGIT_RISE | script.js | 1 | How far the digits rise as they reach the card (0 = none). |
SHAKE | script.js | 1 | How much a wrong field shakes (0 = none). |
TILT | script.js | 1 | How much the card tilts towards the pointer. |
For the card step of a checkout, a subscription or a booking: whoever pays sees the card fill in at once, understands where the security code is and knows what to fix before pressing Pay.
The same animation: the card is sized on both the width and the height of the box, the fields get a little shorter and a tap does what the pointer does; the numeric keyboard opens by itself for the number, expiry and CVC.
No flip, tilt or shake: the digits and letters fade in, the card goes from front to back with a cross-fade, the wrong field turns red without moving and the frame moves by fading out and in again.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 9.5 KB; the libraries: GSAP 28 KB.
Tested on 25 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.