Skip to content
animorio
IT
All components

Referral card

Cards, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.5 KBGSAP 28 KBFreeDownload the zip

The invite-a-friend card of Tallow, a made-up savings app: «Give $20, get $20». Below it sits your personal link in a pill, with Copy squashing and turning into «Copied» with a tick drawing itself; then the row of friends you invited, each with an initial in a circle and their state on a label: Priya goes from Invited to Joined, Tomás from Joined to «Earned $20», and the label changes width on a spring while the text rolls. The gift at the top hops, the bar to the free month fills from 1 to 2 of 3 going a pixel past, and the credit rolls from $20 to $40. On white, with a single violet accent.

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>
<!--
  "Referral 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>Referral card</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/jetbrains-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the invite-a-friend card of Tallow, a made-up savings app: give $20, get $20. Your personal link with Copy,
         the friends you invited with their state, the bar to the next reward and the credit you have earned -->
    <section class="card" data-card aria-label="Tallow, invite friends">
      <span class="card__edge" aria-hidden="true"></span>

      <header class="head">
        <span class="gift" aria-hidden="true">
          <svg viewBox="0 0 24 24" data-gift>
            <g data-lid>
              <rect class="gift__lid" x="3.6" y="8.2" width="16.8" height="4" rx="1.2"/>
              <path class="gift__bow" d="M12 8.2c-1.4-3.4-5.4-3.7-5.4-1.4 0 1.2 1.6 1.4 5.4 1.4zM12 8.2c1.4-3.4 5.4-3.7 5.4-1.4 0 1.2-1.6 1.4-5.4 1.4z"/>
            </g>
            <rect class="gift__box" x="4.8" y="12.2" width="14.4" height="8.4" rx="1.2"/>
            <path class="gift__ribbon" d="M12 8.2v12.4"/>
          </svg>
        </span>
        <div class="head__txt">
          <p class="brand">Tallow · Rewards</p>
          <h1 class="title">Give $20, get $20</h1>
          <p class="sub">When a friend makes their first deposit, you both get $20.</p>
        </div>
      </header>

      <!-- the personal link -->
      <div class="link">
        <span class="link__url" data-url>tallow.app/r/mira-4k2</span>
        <button class="copy" type="button" data-copy aria-label="Copy your invite link">
          <span class="copy__bg" data-copy-bg aria-hidden="true"></span>
          <span class="copy__face" data-cface="copy">
            <svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><rect x="5.2" y="5.2" width="8" height="8" rx="1.6"/><path d="M10.8 5.2V4.4c0-.9-.7-1.6-1.6-1.6H4.4c-.9 0-1.6.7-1.6 1.6v4.8c0 .9.7 1.6 1.6 1.6h.8"/></svg>
            <span>Copy</span>
          </span>
          <span class="copy__face" data-cface="done" aria-hidden="true">
            <svg class="ico" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 8.4 6.6 11.2 12.4 5" pathLength="1" data-ctick/></svg>
            <span>Copied</span>
          </span>
        </button>
      </div>

      <!-- the friends you invited -->
      <ul class="friends" aria-label="Friends you invited">
        <li class="friend" data-friend>
          <span class="av" style="--av:#e9e3ff;--avt:#4a32c4" aria-hidden="true"><span>L</span></span>
          <span class="who"><b>Lena Park</b><small>Joined Nov 18</small></span>
          <span class="state" data-state="earned"><span class="state__txt">Earned $20</span></span>
        </li>
        <li class="friend" data-friend>
          <span class="av" style="--av:#f2ede4;--avt:#6b5a3e" aria-hidden="true"><span>T</span></span>
          <span class="who"><b>Tomás Ruiz</b><small data-when>Joined today</small></span>
          <span class="state" data-state="joined"><span class="state__txt">Joined</span></span>
        </li>
        <li class="friend" data-friend>
          <span class="av" style="--av:#e6f0f4;--avt:#2f5a6b" aria-hidden="true"><span>P</span></span>
          <span class="who"><b>Priya Nair</b><small data-when>Invited 2 days ago</small></span>
          <span class="state" data-state="invited"><span class="state__txt">Invited</span></span>
        </li>
      </ul>

      <!-- the bar to the next reward -->
      <div class="goal">
        <p class="goal__txt"><span class="goal__face" data-gface><b class="roll" data-done></b> of 3 to unlock a free month</span></p>
        <div class="bar" aria-hidden="true">
          <span class="bar__fill" data-fill></span>
          <span class="bar__notch" style="left:33.333%"></span>
          <span class="bar__notch" style="left:66.666%"></span>
        </div>
      </div>

      <!-- the credit -->
      <div class="credit">
        <span class="credit__lab">Your credit</span>
        <span class="credit__val">$<span class="roll" data-credit></span></span>
      </div>

      <p class="sr" aria-live="polite" data-live></p>
    </section>
  </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.

46 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Referral 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 hover Copy swells with a bounce and its label widens on the width axis; on tap it squashes and springs back, really copies the link, the link turns violet for a moment and the pill goes dark with «Copied» and a tick drawing itself; two seconds later it is back to «Copy». Tapping Priya’s or Tomás’s row moves the friends one step on: Priya goes from Invited to Joined, Tomás from Joined to «Earned $20». Each label changes colour, the old text leaves upwards, the new one comes in from below and the width adapts on a spring with a small bump; the line under the name rolls too («Joined just now», «First deposit today»). The gift at the top lifts its lid, the bar fills from one third to two thirds going a pixel past and coming back, «1 of 3» becomes «2 of 3» and the credit rolls from $20 to $40. Tapping again takes everything back. If nobody touches it, the demo plays by itself and starts over.

How it works

The two faces of Copy

«Copy» and «Copied» sit on top of each other, absolutely positioned and centred with inset 0 and flex, inside a fixed-width button: changing label the button does not jump and the tick stays centred.

The label that changes width

A hidden ruler with the same font measures the new text; GSAP takes the label’s width to that measure on a spring, while the old text leaves upwards and the new one comes in from below. On resize and once the fonts are loaded the widths are measured again.

Rolling digits

Each digit of the credit and of the count is a window over a 0-9 column: GSAP moves the column by yPercent −10 per digit with back.out. The leading zero is hidden, so $20 never reads $020.

The bar a pixel past

The bar is a scaleX from 0 to 1: GSAP takes it to the new value plus a pixel and a half (measured on the real width) and then settles it on a spring.

Values to change

NameFileDefaultWhat it changes
REWARDscript.js20Dollars each friend earns you (and them).
GOALscript.js3Friends needed for the free month.
SPRINGscript.js0.45How springy the labels, the bar and Copy are (lower, more bounce).
LABEL_TIMEscript.js0.55Seconds a label takes to change.
BAR_TIMEscript.js0.9Seconds the bar takes to fill.
SQUASHscript.js0.88How flat Copy gets when pressed (1 = not at all).
HOLDscript.js2.4Seconds the finished state stays before the demo starts over.
IDLEscript.js7Seconds after your last touch before the demo plays by itself again.

Try them in the Playground

When to use it

On the rewards or profile page of an app, an online bank, a subscription or a shop that rewards people for bringing friends: the link copies with one tap and every friend who moves a step on shows straight away, in the credit and in the bar to the reward.

On phones

Everything is in em and the size depends on both the width and the height of the window, so the card fits the phone box whole. Copy and the friend rows are real tap targets, tall enough for a thumb; a link that is too long is cut with an ellipsis.

With reduced motion

No springs, squashes or rolling: texts and labels swap with a fade, digits and the bar are at the right value straight away and the gift stays still.

Pitfalls

  • Copy’s two faces are absolutely positioned inside a fixed-width button: «Copied», longer, in the flow would widen the button and push the tick off centre.
  • The label width is measured with a hidden ruler with the same font and size, and measured again after document.fonts.ready: measured with the fallback font it stays too narrow.
  • The gift lid turns with svgOrigin because it is a group inside the svg, not the whole svg.
  • GSAP does not re-read percentages from CSS: the bar moves with scaleX from a left origin, not with its width.

Libraries

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

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

Testing

Tested on 2 December 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