Skip to content
animorio
IT
All components

Gift card balance field

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

The gift card step in the checkout of Larkwell, a made-up homeware shop, on a soft warm page with a grain. Above sits the dark glass card with an apricot and lilac aurora drifting slowly inside; below, the field with the sixteen characters of the code in four groups. Every character lands in the field and on the card at the same moment, rising out of a blur, a caret slides on a spring and, once a group is complete, its four short lines fuse into one. A code already used makes the field shake and turn red; a good one lifts the card, sweeps the light across it, unblurs the value while it rolls up to 75 dollars, stamps Redeemed and grows the store credit underneath.

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>
<!--
  "Gift card balance 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 gift card field that reveals the balance</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the gift card step of a checkout for Larkwell, a made-up homeware shop: above, the card in dark glass with
         its aurora inside; below, the field where the sixteen characters of its code are typed. Every character
         lands in the field and, at the same time, on the card; the value on the card stays blurred until the code
         is checked, then it rolls up and the store credit underneath grows by the same amount -->
    <div class="redeem" data-wrap>
      <div class="gift" data-gift>
        <div class="gift__body" data-gift-body>
          <span class="gift__aurora" aria-hidden="true">
            <span class="gift__blob gift__blob--a" data-blob-a></span>
            <span class="gift__blob gift__blob--b" data-blob-b></span>
            <span class="gift__blob gift__blob--c" data-blob-c></span>
          </span>
          <span class="gift__grain" aria-hidden="true"></span>
          <span class="gift__sheen" data-sheen aria-hidden="true"></span>
          <span class="gift__edge" data-edge aria-hidden="true"></span>
          <div class="gift__head">
            <span class="gift__brand" data-brand>Larkwell</span>
            <span class="gift__kind">Gift card</span>
          </div>
          <div class="gift__code" data-card-code aria-hidden="true"></div>
          <div class="gift__foot">
            <span class="gift__value">
              <span class="gift__label">Value</span>
              <span class="gift__amount" data-amount>$00.00</span>
            </span>
            <span class="gift__stamp" data-stamp aria-hidden="true">
              <svg viewBox="0 0 16 16"><path data-stamp-check pathLength="1" d="M3.6 8.4l2.9 2.9 5.9-6.4"/></svg>
              <span>Redeemed</span>
            </span>
          </div>
        </div>
      </div>

      <form class="panel" data-form novalidate>
        <label class="panel__label" for="gift-code">Gift card code</label>
        <div class="box" data-box>
          <span class="box__ring" data-ring aria-hidden="true"></span>
          <span class="box__scan" data-scan aria-hidden="true"></span>
          <div class="box__slots" data-slots aria-hidden="true"></div>
          <span class="box__caret" data-caret aria-hidden="true"><span class="box__caret-bar"></span></span>
          <input class="box__input" id="gift-code" data-input type="text" maxlength="24" autocomplete="off" autocapitalize="characters" autocorrect="off" spellcheck="false" aria-describedby="gift-msg">
          <button class="box__btn" type="submit" data-btn disabled>
            <span class="box__btn-face" data-btn-face>
              <span class="box__btn-words" data-btn-words>Redeem</span>
              <svg class="box__btn-spin" data-btn-spin viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="7" pathLength="1"/></svg>
              <svg class="box__btn-check" viewBox="0 0 16 16" aria-hidden="true"><path data-btn-check pathLength="1" d="M3.4 8.4l3 3 6.2-6.6"/></svg>
            </span>
          </button>
        </div>
        <p class="msg" id="gift-msg" data-msg aria-live="polite">
          <span class="msg__icon" aria-hidden="true">
            <svg class="msg__i msg__i--help" viewBox="0 0 16 16"><rect x="2.5" y="4" width="11" height="8" rx="1.6"/><path d="M2.5 6.6h11"/></svg>
            <svg class="msg__i msg__i--err" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6"/><path d="M8 4.9v3.6M8 10.9v.1"/></svg>
            <svg class="msg__i msg__i--ok" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6"/><path d="M5.3 8.2l1.9 1.9 3.6-3.9"/></svg>
          </span>
          <span class="msg__text" data-msg-text>16 characters, on the back of your card</span>
        </p>
        <div class="credit">
          <span class="credit__label">Store credit</span>
          <span class="credit__right">
            <span class="credit__plus" data-plus>+$75.00</span>
            <span class="credit__amount" data-credit>$12.40</span>
          </span>
        </div>
      </form>
    </div>
  </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.

35 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 “Gift card balance 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 page the colour of warm paper, with a soft light in the middle and a very fine grain, there are only two pieces of Larkwell’s checkout. Above, the gift card: a dark glass rectangle with round corners, its one pixel edge brighter at the top, a layered shadow and an apricot halo underneath. Inside, three blurred lights, apricot and lilac, drift slowly on their own, and a grain turns them into frosted glass. At the top there are the Larkwell name and Gift card, in the middle sixteen thin lines in four groups, at the bottom Value and a blurred amount. Below, a white panel with the Gift card code label, the very light grey field with sixteen short lines in four groups, the dark Redeem button still off, a help line with the card icon and, after a thin rule, Store credit $12.40. Touched, the field takes an apricot ring and the caret appears. Every character typed comes into the field with a little hop out of a blur and, at the same time, rises on the card in place of its line; the caret slides to the next slot with a small bounce and, when a group is complete, its four short lines fuse into one on a spring. Meanwhile a band of light crosses the card as far as the code has got and the edge catches it. With the sixteenth character Redeem lights up. Pressed, it goes down, the word rises away, a spinning arc comes in, a faint light runs along the field and the band goes back and forth on the card. If the code was already used the field shakes on a damped spring, the ring and the letters turn red, the characters on the card fade and shake too, and This card was already redeemed appears underneath. If it is good the ring turns green, the button draws a check and becomes Added, the card rises a few pixels and settles, the light sweeps all the way across it, the value loses its blur while the digits roll up to $75.00, a green Redeemed stamp comes in with its check, and underneath +$75.00 arrives while the credit rolls from $12.40 to $87.40. By itself it goes round: first a code already used, then a good one.

How it works

A real input under the slots

The sixteen slots are drawn, but over them lies a real input, transparent and at 16 pixels (so the iPhone does not zoom): it takes the keyboard, backspace, paste and the phone’s keyboard. On every input event the value is cleaned (upper case, only letters and digits, sixteen at most), compared with the previous code slot by slot, and only the slots that changed animate: new ones come in, removed ones go out.

The character that arrives in two places

Every new character starts at once in the field and on the card: in the field with a fromTo from 7 pixels below, scale 0.7 and blur(3px) with back.out(2.6), on the card out of a wider blur with expo.out and forty milliseconds of delay, so the two arrivals read as one reflected. After four characters the group’s four short lines fade and a single line grows from scaleX 0.55 with back.out(3).

The caret and the band of light

The caret is a gsap.quickTo on x with back.out: the position is read from the slot’s getBoundingClientRect, and on resize it snaps back to its place. The band of light on the card is an oblique gradient moved by the --sx variable, which follows how much of the code is written; the same value, scaled, moves the bright spot of the edge, a one pixel ring cut out with mask-composite, so the edge and the glass light up together.

The check and the error

Redeem swaps the word for an SVG arc spinning with svgOrigin, runs a light through the field with the --scan variable and moves the band back and forth. With a code already used the field shakes with keyframes from -8 to 0 pixels, smaller and smaller, like a damped spring; the letters turn red and the message changes dropping and rising again, with the icon swapping on a small bounce.

The value that reveals itself

On success a single object carries the number, the blur and the opacity of the value: the number rolls from 0 to 75 with power3.out while --blur drops from 6 to 0 pixels, with tabular digits that never change width. The card rises with back.out and settles, the stamp comes in with its check drawn by stroke-dashoffset, and the store credit grows by the same amount, starting green and going back to the colour of the text.

Values to change

NameFileDefaultWhat it changes
BRANDscript.js'Larkwell'The shop written on the card and in the message.
USED_CODEscript.js'K7Q2MX4D8RLP2HVA'The code already used, which gives the error.
GOOD_CODEscript.js'H4NB9TQE2WRX7LMC'The good code it redeems by itself.
CARD_VALUEscript.js75The value of the good card, in dollars.
START_CREDITscript.js12.4The store credit before redeeming.
TYPE_SPEEDscript.js0.085The seconds between one character and the next when it types by itself.
CHECK_TIMEscript.js1.25The seconds the code takes to be checked.
LIFTscript.js6The pixels the redeemed card rises.
AUTOscript.jstrueWhether it goes round by itself until someone touches it.

Try them in the Playground

When to use it

In the checkout or account page of an online shop, a delivery app, a subscription or a hotel that sells vouchers: wherever a gift card or a prepaid code is redeemed and the person typing should see on the card what they are writing, understand the error without reading and watch the credit grow.

On phones

On the phone the card and the panel are 88% of the screen wide, the characters shrink with the width and the card never grows past the height that is left; the field opens the phone’s keyboard already in capitals, the input is at 16 pixels and the iPhone does not zoom. Without a mouse the light on the card follows only the code.

With reduced motion

Nothing moves: the characters fade in without rising, the field does not shake but turns red, the card does not rise and the light does not cross it, the aurora stays still; the value reveals itself and the digits roll, the stamp and the check draw themselves.

Pitfalls

  • After redeeming the field is full: a key pressed added the character to the old code and the cleaning to sixteen characters threw it away, so the keyboard seemed broken. On keydown, if the code is redeemed, the field empties before the input event arrives, and the character becomes the first of the new code.
  • The caret placed with offsetLeft ended up off inside the groups with their gap: the position is read from the slot’s getBoundingClientRect relative to the field, and on resize it snaps back without the spring.
  • The value rolling from 0 to 75 changed width at every digit and the stamp next to it wobbled: tabular digits and a leading zero while the number has a single digit ($05.20), so the line stays still.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, Geist Mono (font variabile) 5.3.0.

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

Testing

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