Skip to content
animorio
IT
Back to the library

Loyalty token card

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

The rewards card of Fernhall, a made-up coffee roaster, dark on a near black page, like a Dribbble shot: every Check in drops a brushed copper token with a stamped bean through the slot of a small glass vault. The tokens are real bodies written by hand: gravity, bounces on the floor, the walls and each other, friction and rolling, and the counter rolls when a token lands, with a ring of light and a small jolt of the glass. The pointer stirs them as it passes, a tap flicks one up. On the tenth a thin streak crosses the glass, the tokens warm up and the button turns amber: Redeem splits the floor open and the tokens drop out while the number rolls back to zero.

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>
<!--
  "Loyalty token card" 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 loyalty card with tokens that fall into the vault</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 rewards card of a made-up coffee roaster, Fernhall: every check in drops a brushed copper token through
         the slot of a small glass vault. The tokens are real bodies, written by hand: gravity, bounces on the floor
         and on each other, rolling spin. The pointer stirs them, a tap flicks one up. Ten tokens and the drink is
         ready: Redeem opens the floor and they all drop out, the counter rolling back to zero -->
    <section class="card" data-card aria-label="Fernhall rewards">
      <header class="head">
        <div class="brand">
          <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true">
            <path d="M12 3.2c3.6 2.4 5.6 5.4 5.6 9 0 3.4-2.5 6.1-5.6 6.1s-5.6-2.7-5.6-6.1c0-3.6 2-6.6 5.6-9Z"/>
            <path d="M12 6.4c-1.1 2.4-1.1 5.6 0 8.8"/>
          </svg>
          <div class="brand__txt">
            <span class="brand__name" data-brand>Fernhall</span>
            <span class="brand__cat">Coffee rewards</span>
          </div>
        </div>
        <span class="tier"><span class="tier__ring" aria-hidden="true"></span>Ember tier</span>
      </header>

      <div class="tally">
        <p class="tally__big">
          <span class="roll" data-roll aria-hidden="true"><span class="roll__n">0</span></span>
          <span class="tally__of">/ 10 stamps</span>
        </p>
        <p class="tally__note" data-note>10 more for a free flat white</p>
      </div>

      <div class="vault" data-vault>
        <span class="vault__glow" data-glow aria-hidden="true"></span>
        <span class="vault__slot" aria-hidden="true"><span class="vault__lip"></span></span>
        <div class="vault__tokens" data-tokens></div>
        <span class="vault__floor" aria-hidden="true">
          <span class="vault__hatch vault__hatch--l" data-hatch-l></span>
          <span class="vault__hatch vault__hatch--r" data-hatch-r></span>
        </span>
        <span class="vault__glass" aria-hidden="true"></span>
        <span class="vault__streak" data-streak aria-hidden="true"></span>
      </div>

      <div class="track" data-track aria-hidden="true"></div>

      <button class="btn" type="button" data-btn>
        <span class="btn__face" data-face>
          <span class="btn__words" data-words>Check in</span>
          <svg class="btn__icon" viewBox="0 0 16 16" aria-hidden="true">
            <path class="btn__plus" data-plus d="M8 3.5v9M3.5 8h9"/>
            <path class="btn__cup" data-cup d="M3.6 6.2h7.2v2.6a3.6 3.6 0 0 1-7.2 0Zm7.2 1h.8a1.5 1.5 0 0 1 0 3h-1.2M5.6 2.8v1.4M8 2.4v1.8"/>
          </svg>
        </span>
      </button>
    </section>

    <p class="sr" aria-live="polite" data-live></p>
    <svg class="cursor" data-cursor viewBox="0 0 24 24" aria-hidden="true"><path d="M5 2.8v16.4l4.2-4 2.8 6.2 2.9-1.3-2.8-6.1h5.9Z"/></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.

28 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 “Loyalty token card” 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 near black page with fine grain and a warm haze, a dark card with a lit edge: at the top the Fernhall mark (a bean drawn in amber lines) with Coffee rewards and the Ember tier pill, below it the big stamp count with / 10 stamps and, on the right, how many are left for a free coffee. In the middle a dark glass vault with a slot at the top, a diagonal sheen and a warm light that rises from the floor as it fills; under it ten thin segments and the light Check in button with a plus. Each press gives under the finger and comes back on a spring, the plus turns, and a brushed copper token with a stamped bean comes through the slot spinning: it falls, bounces on the floor or the others, rolls and settles in the heap. When it touches the floor or another token the counter rolls to the new number, a segment fills, a shine crosses the token, a thin ring grows from the point of impact and the glass jolts by a pixel or two. The pointer over the glass pushes away the tokens it touches, a tap flicks one up. On the tenth a thin anamorphic streak crosses the glass, the tokens take a glow and the button turns amber with a cup: Redeem flat white. Pressed, the floor splits open, the tokens drop out one after the other as the number counts down to zero, the floor closes with a small bounce and the line says Enjoy your flat white. Left alone, a drawn pointer checks in up to ten, stirs the tokens, flicks one and redeems the reward.

How it works

The bodies

Every token is a circle with a position, a velocity, an angle and a spin. Each frame the time is held to 1/30 s and split in three steps: gravity adds speed, a very light air drag takes some away, then the position moves on (semi-implicit Euler). Walls and floor send the speed back times BOUNCE, and under 60 px/s the bounce is switched off, so a token settles instead of trembling.

Tokens hitting tokens

For every pair closer than two radii the circles are pushed apart along their line, three times a step; the one on the floor is heavier and moves little. Then an impulse along the normal with restitution and one along the tangent capped by Coulomb friction (FRICTION times the normal impulse), which also spins the tokens: that is how they roll off the heap.

The counter on landing

The number goes up not on the click but when the token touches the floor or a token that has already landed: that is when the shine crosses it, the ring of light grows at the point of impact and the glass jolts (elastic.out), all scaled by the speed of the hit. The digits roll with two elements, the old one leaving upwards on power3.in and the new one coming from below on back.out.

The pointer that stirs

Inside the glass the pointer is a pushing field: every token closer than 2.3 radii gets an acceleration away from it, stronger the closer it is, a little upwards, plus part of the pointer's own speed. A tap on a token gives it FLICK px/s upwards.

The reward

On the tenth token a one pixel line with an amber glow crosses the glass, the tokens take their glow one after the other and the button changes words and icon. Redeem slides the two halves of the floor aside, takes the floor out of the physics and the tokens drop out of the glass, which clips them; the number goes down with every token that leaves.

Values to change

NameFileDefaultWhat it changes
BRANDscript.js"Fernhall"The name of the made-up roaster, at the top.
GOALscript.js10How many tokens the free coffee takes.
GRAVITYscript.js1900Gravity in pixels per second per second.
BOUNCEscript.js0.42How much the tokens bounce (0 none, 0.8 a lot).
FRICTIONscript.js0.12The friction between tokens and on the floor.
STIRscript.js5200How hard the pointer stirs the tokens.
FLICKscript.js620The upward kick of a tapped token.
STARTscript.js4How many tokens are already in at the start of each round.
SPEEDscript.js1How fast the drawn pointer goes.
LOOPscript.jstrueLeft alone, the pointer does the round again and again.

Try them in the Playground

When to use it

For the app or site of a coffee shop, a bakery, an ice cream parlour, a shop or a service with a points card: when stamps should feel like something you really put aside, with weight, and the reward a moment to celebrate. It also fits the jar of a savings app or the credits of any app.

On phones

The same physics with adapted sizes: the card takes almost the full width, the glass is sized on width and height and the tokens' radius on the glass, so ten always fit in two rows. With a finger a tap in the glass flicks a token and dragging stirs them.

With reduced motion

No falls or bounces: each token fades in already in its place in the heap, the number changes without rolling, the segments fill gently, and Redeem fades the tokens away.

Pitfalls

  • The time step has to be capped (here at 1/30 s) and split in substeps: after a background tab a one second frame sends the tokens straight through the floor.
  • Without a threshold under which the bounce stops, a resting heap trembles for ever: here under 60 px/s the token settles, and under 50 a hit between tokens has no restitution.
  • The counter must follow the landing, not the click: pressing fast, tokens in the air do not count until they touch.
  • The metal's light must stay put while the token spins: the light sits on the outer element that moves, the stamped bean on the inner one that turns. Rotating the whole would turn the light as well.
  • On resize the positions must be scaled to the new size of the glass, or the tokens are left outside the walls.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 9 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 animations