Skip to content
animorio
IT
All components

Buy me a coffee card

Cards, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 5.7 KBGSAP 28 KBFreeDownload the zip

The card at the end of a post to support the writer: you choose one, three or five coffees and the drawn cup fills to that level, the steam wakes up and the total in the button is recounted. Pressed, the button says thank you and the cup makes a small toast.

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>
<!--
  "Buy me a coffee 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>Buy the author a coffee card with the cup that fills and the total that counts</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 "buy me a coffee" card at the end of a blog post: choosing one, three or five coffees fills the cup,
         wakes the steam and recounts the total; the button thanks you and the cup makes a small toast -->
    <form class="cf" data-cf onsubmit="return false">
      <div class="cf__top">
        <svg class="cup" viewBox="0 0 72 72" aria-hidden="true">
          <defs><clipPath id="cf-in"><path d="M17 27h34l-3.200 22.500a6 6 0 0 1-5.900 5.100H26.100a6 6 0 0 1-5.900-5.100Z"></path></clipPath></defs>
          <g data-steam><path class="cup__steam" pathLength="1" d="M26 20c-3-3.500 3-5.500 0-9"></path><path class="cup__steam" pathLength="1" d="M34 19c-3-4 3-6.500 0-11"></path><path class="cup__steam" pathLength="1" d="M42 20c-3-3.500 3-5.500 0-9"></path></g>
          <g data-cup>
            <path class="cup__handle" d="M50.500 32h3.500a6.500 6.500 0 0 1 0 13h-5"></path>
            <path class="cup__glass" d="M17 27h34l-3.200 22.500a6 6 0 0 1-5.900 5.100H26.100a6 6 0 0 1-5.900-5.100Z"></path>
            <g clip-path="url(#cf-in)"><rect class="cup__coffee" data-coffee x="15" y="27" width="38" height="29"></rect><rect class="cup__crema" data-crema x="15" y="27" width="38" height="2.600"></rect></g>
            <path class="cup__body" d="M17 27h34l-3.200 22.500a6 6 0 0 1-5.900 5.100H26.100a6 6 0 0 1-5.900-5.100Z"></path>
            <path class="cup__shine" d="M22.500 31.500l1.900 14"></path>
          </g>
          <path class="cup__saucer" d="M12 60.500h44"></path>
        </svg>
        <div class="cf__say">
          <span class="cf__kicker">Enjoyed the essay?</span>
          <span class="cf__title" id="cf-title">Buy Mara a coffee</span>
          <span class="cf__sub">It keeps the newsletter free.</span>
        </div>
      </div>

      <div class="cf__row" role="radiogroup" aria-labelledby="cf-title" data-row>
        <span class="cf__thumb" data-thumb aria-hidden="true"></span>
        <label class="opt"><input type="radio" name="cups" value="1"><span>One</span></label>
        <label class="opt"><input type="radio" name="cups" value="3"><span>Three</span></label>
        <label class="opt"><input type="radio" name="cups" value="5"><span>Five</span></label>
      </div>

      <button class="cf__go" type="submit" data-go>
        <span class="cf__go-fill" aria-hidden="true"></span>
        <span class="cf__go-text"><span data-gotext>Support with <b data-total></b></span></span>
        <svg class="cf__go-tick" viewBox="0 0 20 20" aria-hidden="true"><path data-tick pathLength="1" d="M4.500 10.400 8.300 14 15.500 6.200"></path></svg>
      </button>
      <p class="sr" data-live aria-live="polite"></p>
    </form>

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

18 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 “Buy me a coffee 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 white, a card: on the left a line-drawn cup on its saucer, on the right “Buy Mara a coffee” with two small lines; below, a row of three choices (One, Three, Five) with a white tile sliding under the chosen one, and at the bottom a black pill button “Support with €9”. On opening the coffee rises in the cup. Choosing another amount, the coffee rises or falls past the mark and settles, with the crema following, the threads of steam draw themselves (one, two or three), the cup tilts towards the change and the total counts. Pressing the button, its fill turns coffee-coloured, the text rolls to “Thank you, truly”, the tick draws itself and the cup lifts and tilts in a toast that dies out on a spring. They are real radios: arrows and Tab work.

How it works

The cup

The coffee is a rectangle inside a clipPath shaped like the cup: GSAP only moves its y (29 units for fully empty), with back.out(1.5), so the level passes the mark and comes back like a liquid. The crema is a second rectangle with the same y.

The steam

Three paths with pathLength 1: the ones needed draw themselves with stroke-dashoffset staggered by a tenth, the others withdraw. They have opacity 0 when off, so as not to leave dots.

The total and the thanks

The total counts with power2.out inside the button. At the thank you the text rolls (the total’s node is found again after each change of text), and the cup rotates 12 degrees on its base and comes back with elastic.out.

Values to change

NameFileDefaultWhat it changes
PRICEscript.js3The price of one coffee, in euros.
STARTscript.js1The choice at the start: 0 one coffee, 1 three, 2 five.
ACCENTscript.js#a8612cThe colour of the coffee.
POURscript.js0.9How many seconds the cup takes to fill.
HOLDscript.js2.2Alone: how many seconds the thank you stays before starting over.
LOOPscript.jstrueLeft alone, a pointer chooses and offers.

Try them in the Playground

When to use it

At the end of the posts of a personal blog or a newsletter, on the “support me” page of someone making podcasts, music or open source, wherever a small contribution has three sizes.

On phones

The same card, as wide as the screen; below 350 pixels the cup drops to 64 and the title to 17. The three choices and the button stay 38 and 50 pixels high.

With reduced motion

The cup is already at its level and changes without rising, the steam appears, the total changes without counting and the thank you arrives without rolling or a toast.

Pitfalls

  • Changing the button’s text removes the total’s node and creates another: the script looks it up each time, otherwise the count would write into a detached element.
  • The tile under the choices has its x in pixels: it must be recalculated on resize.
  • The level has the spring, the total does not: money never overshoots the figure.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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