
The elastic button
Buttons, Hover, Text
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.
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>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
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 siteInside 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 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.
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 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 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.
| Name | File | Default | What it changes |
|---|---|---|---|
LABEL | script.js | Invite a friend | The label of the closed button. |
HOST | script.js | plume.cash/r/ | The first part of the invite link, in grey. |
CODE | script.js | NORA-20 | The personal code, the part that copies itself. |
REWARD | script.js | $20 | The reward written on the badge and on the ticket, for you and for the friend. |
ACCENT | script.js | #5fe3a6 | The colour of the code, the check and the badge. |
TYPE_SPEED | script.js | 0.045 | How many seconds for each letter of the link as it types. |
SPRING | script.js | 0.75 | How long the spring that widens the pill lasts, in seconds. |
HOLD | script.js | 1.3 | How many seconds the ticket stays out before folding. |
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.
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.
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.
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.
Tested on 12 November 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.