Skip to content
animorio
IT
All components

Invite a friend button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 10 KBGSAP 28 KBFreeDownload the zip

The Invite a friend button of a made-up payments app's referral programme, in a premium minimal style on white: pressed, the dark pill widens and the invite link types itself letter by letter; the code selects and copies itself with a shine, a “$20 for you, $20 for them” ticket slides out of the button, folds on its perforation and slips back in, then Link copied draws its check and the button returns to rest.

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>
<!--
  "Invite a friend button" 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 Invite a friend button with the link that copies and the reward that slides out</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">
    <!-- the Invite a friend button of a made-up money app's referral programme: pressed, the pill widens and types the
         invite link, the code part copies itself with a shine, a small reward ticket slides out of the pill, folds on
         its perforation and slips back in, then Link copied draws its check and the button comes back -->
    <div class="wrap" data-wrap>

      <!-- the reward ticket: it lives in a slot whose bottom edge is the middle of the pill, so it comes out of the button -->
      <div class="slot" aria-hidden="true">
        <div class="ticket" data-ticket>
          <div class="ticket__half ticket__bottom">
            <span class="ticket__col"><b data-you>$20</b><i>for you</i></span>
            <span class="ticket__rule"></span>
            <span class="ticket__col"><b data-them>$20</b><i>for them</i></span>
          </div>
          <div class="ticket__half ticket__top" data-tickettop>
            <div class="ticket__face ticket__front">
              <svg class="ticket__mark" viewBox="0 0 24 24"><path d="M5 17.5c3.2-.4 6.4-2.6 8.6-5.6 1.6-2.2 2.9-4.8 5.4-7.4-.2 3.9-1.3 7.3-3.4 9.9-2.3 2.8-5.6 4.1-10.6 3.1Z"></path><path d="M5 17.5 13.2 9.8"></path></svg>
              <span class="ticket__label">Plume referral</span>
              <span class="ticket__tag">Both get paid</span>
            </div>
            <div class="ticket__face ticket__back"><span class="ticket__weave"></span></div>
          </div>
          <span class="ticket__shine" data-ticketshine></span>
        </div>
      </div>

      <div class="pill" data-pill>
        <span class="pill__floor" aria-hidden="true"></span>
        <span class="pill__halo" data-halo aria-hidden="true"></span>
        <div class="pill__clip">
          <span class="pill__grain" aria-hidden="true"></span>
          <span class="pill__sheen" data-sheen aria-hidden="true"></span>

          <button class="invite" type="button" data-invite aria-expanded="false" aria-controls="invite-panel">
            <span class="invite__in" data-invitein>
              <svg class="gift" data-gift viewBox="0 0 24 24" aria-hidden="true">
                <path d="M5.4 11.2v7a1.6 1.6 0 0 0 1.6 1.6h10a1.6 1.6 0 0 0 1.6-1.6v-7M12 11v8.8"></path>
                <g data-lid><rect x="4" y="7.6" width="16" height="3.6" rx="1.2"></rect>
                <path d="M12 7.6c-1-2.6-3.8-3.6-4.8-2.2-.8 1.2.6 2.2 4.8 2.2Zm0 0c1-2.6 3.8-3.6 4.8-2.2.8 1.2-.6 2.2-4.8 2.2Z"></path></g>
              </svg>
              <span class="invite__word" data-word>Invite a friend</span>
              <span class="invite__badge" data-badge><span data-badgetext>$20</span></span>
            </span>
          </button>

          <div class="panel" id="invite-panel" data-panel role="group" aria-label="Your invite link">
            <span class="avatar" data-avatar aria-hidden="true">
              <svg viewBox="0 0 24 24"><path d="M10.4 13.6a3.6 3.6 0 0 0 5.1 0l2.9-2.9a3.6 3.6 0 0 0-5.1-5.1l-1.1 1.1"></path><path d="M13.6 10.4a3.6 3.6 0 0 0-5.1 0l-2.9 2.9a3.6 3.6 0 0 0 5.1 5.1l1.1-1.1"></path></svg>
            </span>
            <span class="link">
              <span class="link__line" data-line><span class="link__host" data-host></span><span class="code" data-code><span class="code__sel" data-sel></span><span class="code__text" data-codetext></span><span class="code__glint" data-glint></span><span class="code__ghost" data-codeghost></span></span><span class="caret" data-caret></span></span>
              <span class="link__sub"><span class="link__subin" data-sub>Your invite link</span></span>
            </span>
            <button class="copy" type="button" data-copy aria-label="Copy the invite link again">
              <svg class="copy__ic" viewBox="0 0 24 24" aria-hidden="true">
                <g data-sheets><rect x="8.6" y="8.6" width="10.8" height="10.8" rx="2.4"></rect><path d="M15.4 8.6V7a2.4 2.4 0 0 0-2.4-2.4H7A2.4 2.4 0 0 0 4.6 7v6A2.4 2.4 0 0 0 7 15.4h1.6"></path></g>
                <path class="copy__check" data-minicheck d="M7.4 12.4 10.6 15.6 16.8 8.8"></path>
              </svg>
            </button>
          </div>

          <div class="done" data-done aria-hidden="true">
            <svg class="done__ic" viewBox="0 0 24 24"><circle data-ring cx="12" cy="12" r="9"></circle><path data-check d="M7.8 12.4 10.8 15.4 16.4 9.2"></path></svg>
            <span class="done__word">Link copied</span>
          </div>
        </div>
        <span class="pill__edge" aria-hidden="true"></span>
      </div>
      <p class="sr" data-live aria-live="polite"></p>
    </div>

    <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.

27 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 “Invite a friend button” 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 white background there is just a dark pill sixty pixels tall, its body fading from charcoal to near black, a very fine grain, a one pixel edge that catches the light along the top and soft layered shadows with a faint green glow: inside, a gift box drawn in line, the words Invite a friend and a green $20 badge. On hover the pill lifts by a pixel, the edge thread lights up where the pointer is and follows it, the gift’s lid gives a little hop and the words widen on the wdth axis. Pressed, it squeezes and springs back, the lid pops and the words leave upwards while the pill widens on an elastic spring. On the left a green circle with a chain comes in turning, on the right the white copy button arrives with a bounce, and in the middle the invite link types itself letter by letter with a green caret in front: plume.cash/r/ in grey and then the code NORA-20 in a tile. The caret blinks, the code gets selected from the left in green, jumps by a pixel and a glint runs across it while a copy of it lifts off and fades; the two sheets icon turns away and a check draws in its place, a green halo spreads from the edge and the line below rolls into Code copied. The pill gulps and a paper coloured ticket rises from inside it, with a soft shadow, two notches and a dotted perforation: Plume referral and Both get paid on top, $20 for you and $20 for them in green below; it settles with a sway, a shine crosses it and the line below says You both get $20. Then the top half folds forward on the perforation showing its darker, striped back, the bottom half darkens in the fold’s shadow, the ticket takes a little run up and drops into the button, which swallows it with another jolt. The pieces leave and the pill narrows into Link copied: the circle draws itself, then the check. A moment later the words leave upwards, the pill goes back to its size and Invite a friend returns from below with the gift rocking and the badge bouncing. A drawn pointer shows the whole loop on its own.

How it works

One pill, three contents

Inside the pill a layer with overflow hidden holds the button, the open panel and the Link copied state, all absolutely positioned. The panel is already as wide as the open pill and centred with a negative margin: GSAP only changes the pill’s width (elastic.out to open, back.out to narrow) and the contents uncover themselves from the middle.

The link that types itself

The timeline places one call per letter, TYPE_SPEED seconds apart: the host first, then the code, a little slower. The caret is a green stroke after the text; the code tile stays out of the flow (display none) until its first letter arrives, so the caret always sits right after the words.

The code that copies itself

A green selection grows with scaleX from the left, a slanted glint runs across the tile by moving the --gx variable, and a copy of the code lifts off and fades. Meanwhile navigator.clipboard writes the real link, when the page is secure.

The ticket coming out of the button

The ticket lives in a slot behind the pill, cut at the button’s half height: it rises with back.out and seems to come out from inside. The notches are two radial gradients in each half’s mask, the shadow is a drop-shadow on the whole ticket, so it follows the notches.

The fold on the perforation

The top half turns by -180 degrees in rotationX with transformPerspective, around its bottom edge; halfway through the front switches off and the striped back switches on, while the bottom half darkens through the --shade variable. Then the ticket drops and the pill jolts in scaleY.

Values to change

NameFileDefaultWhat it changes
LABELscript.jsInvite a friendThe label of the closed button.
HOSTscript.jsplume.cash/r/The first part of the invite link, in grey.
CODEscript.jsNORA-20The personal code, the part that copies itself.
REWARDscript.js$20The reward written on the badge and on the ticket, for you and for the friend.
ACCENTscript.js#5fe3a6The colour of the code, the check and the badge.
TYPE_SPEEDscript.js0.045How many seconds for each letter of the link as it types.
SPRINGscript.js0.75How long the spring that widens the pill lasts, in seconds.
HOLDscript.js1.3How many seconds the ticket stays out before folding.

Try them in the Playground

When to use it

On the Invite friends page of a payments app, an online bank or a subscription, in the profile of an app with a referral programme, at the end of a checkout to hand out your code: wherever you want to show at once what both people earn.

On phones

The open pill narrows to the screen width minus thirty-two pixels, the circle, the copy button and the link get slightly smaller and the ticket narrows to 224 pixels; a finger presses like the mouse. Without hover the edge light stays still in the middle.

With reduced motion

No springs, typing, shines or fold: the pill changes width in a moment, the link appears whole, the code is already selected with its check, the ticket fades in and out and Link copied arrives already drawn.

Pitfalls

  • The fromTo tweens placed later in the timeline applied their start values at once: the line under the link vanished, the copy of the code showed early and Invite a friend hid before leaving. Every fromTo in the sequence has immediateRender: false.
  • The empty code tile, hidden with visibility, still took space and the caret floated away from the letters: with display none until its first letter arrives the caret stays right after the text.
  • The ticket is taller than the pill, so it cannot hide behind it: it lives in a slot with overflow hidden whose bottom edge is at the button’s half height, and the part between the slot and the pill’s top edge is covered by the button.
  • Notches made with a mask also cut box-shadows: the shadow is a drop-shadow on the whole ticket, which follows the notched outline.
  • The closed width and the Link copied width are measured on the real words and again once the typeface arrives; the open one is measured again on resize, even mid-animation.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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