Skip to content
animorio
IT
All components

Donate trees button

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

The «Donate» button of a tree-planting fund, in the style of product interface pieces, on white: on hover the amounts fan out above the button, the chosen one drops into it, the button turns green and says «Thank you», and a small tree grows on its edge for every five dollars while the amount raised rolls up and the bar moves on.

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>
<!--
  "Donate trees 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 Donate button with trees growing on its edge</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>
    <!-- a tree-planting fund: the amounts fan out over the button, the chosen one drops in,
         and a tree grows on the button's top edge for every five dollars while the bar below fills -->
    <div class="donor" data-donor>
      <div class="pad" data-pad>
        <div class="amounts" data-amounts role="group" aria-label="Choose an amount">
          <button class="amt" type="button" data-amt="5" tabindex="-1"><span>$5</span></button>
          <button class="amt" type="button" data-amt="10" tabindex="-1"><span>$10</span></button>
          <button class="amt" type="button" data-amt="25" tabindex="-1"><span>$25</span></button>
        </div>
        <svg class="grove" data-grove viewBox="0 0 220 44" aria-hidden="true"></svg>
        <button class="donate" type="button" data-donate data-autoclic aria-expanded="false">
          <span class="donate__fill" data-fill aria-hidden="true"></span>
          <span class="donate__face" data-face>
            <svg class="sap" data-sap viewBox="0 0 20 20" aria-hidden="true">
              <path class="sap__stem" d="M10 17.5V9.2"></path>
              <path class="sap__leaf" data-leaf-l d="M10 11.6C7.2 11.8 5.2 10.2 4.8 7.4 7.6 7.1 9.6 8.6 10 11.6Z"></path>
              <path class="sap__leaf" data-leaf-r d="M10 9.4C10.3 6.4 12.4 4.6 15.4 4.6 15.4 7.6 13.2 9.4 10 9.4Z"></path>
              <path class="sap__soil" d="M6.4 17.5h7.2"></path>
            </svg>
            <span class="donate__words">
              <span class="donate__label" data-idle>Donate</span>
              <span class="donate__label donate__label--done" data-done aria-hidden="true">
                <svg class="tick" viewBox="0 0 16 16"><path data-tick d="M3.4 8.4 6.6 11.4 12.6 4.8"></path></svg>
                <span data-done-text>Thank you</span>
              </span>
            </span>
          </span>
        </button>
      </div>

      <div class="raised" data-raised>
        <p class="raised__line">
          <span class="raised__sum" data-sum>$1,240</span>
          <span class="raised__of">of $2,000 raised</span>
        </p>
        <div class="bar" aria-hidden="true">
          <span class="bar__fill" data-bar></span>
          <span class="bar__gain" data-gain></span>
        </div>
        <p class="raised__note"><span data-trees>248</span> trees planted with Rowan Trust</p>
      </div>
    </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.

25 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 “Donate trees 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 white there is a black pill with a drawn sprout and the word «Donate»; below, «$1,240 of $2,000 raised», a thin black bar on grey and «248 trees planted with Rowan Trust». Hovering the button (or tapping it), the three amounts, $5, $10 and $25, come out from behind in a fan, one after another, on a shallow arc with the middle one higher, while the sprout’s two leaves open. Hovering an amount lifts its pill three pixels; pressed, it squashes. Once chosen, the amount drops into the button, shrinking and fading, the button squashes as if hit and comes back on an elastic, fills green from the centre, «Donate» rises away and «Thank you» arrives with the check drawing itself. On the button’s top edge a small tree grows for every five dollars (one, two or five): first the shadow, then the trunk with a twig, then the crown popping with a bounce, staggered; then each one sways slowly to its own rhythm. Meanwhile the amount raised rolls up, rising two pixels, the tree count follows it and the new part of the bar fills green. After a few seconds the trees sink back into the button, the last ones first, the green fades, «Donate» returns and the green of the bar melts into the black. A drawn pointer gives $25 and then $10 by itself; at the first real touch it steps aside. When the fund gets close to the goal it starts over.

How it works

The amounts in a fan

The three pills all sit in the same spot, above the centre of the button, small and transparent. On opening, GSAP takes each one to its place on a shallow arc (x minus 64, 0 and 64, the middle one 8 pixels higher, rotated minus 7, 0 and 7 degrees) with back.out and a small delay between them; on closing they go back in reverse order.

The amount dropping in

The chosen pill drops 52 pixels and shrinks to 0.45 with power2.in, fading as it reaches the button. At that moment the button squashes (0.92 in height, 1.03 in width) and comes back with elastic.out: you feel the hit.

The trees on the edge

The trees are SVG groups created on the fly, one every PER_TREE dollars, in a drawing resting on the button’s top edge. Each has a shadow, a trunk and a crown made of two circles and a highlight: they grow in that order, each with its svgOrigin at the base, and then the group sways with an endless yoyo of a different length for every tree.

The amount and the bar

The amount raised is a number animated by GSAP and rewritten on every frame with toLocaleString; the bar is two layers with scaleX, the black of what was there and the green up to the new total, which melts into the black on the way back.

The way back

A delayedCall of HOLD seconds sinks the trees back (first the crown, then the trunk), turns off the button’s green and brings back «Donate». The autopilot awaits the tweens as promises and stops at the first real touch, to start again after eight quiet seconds.

Values to change

NameFileDefaultWhat it changes
FANscript.js0.5How long the spring that fans the amounts out above the button lasts, in seconds.
GROWscript.js0.75How long a tree takes to grow on the button’s edge, in seconds.
HOLDscript.js2.6How many seconds «Thank you» stays before «Donate» comes back.
PER_TREEscript.js5How many dollars make a tree.
START_RAISEDscript.js1240How much has already been raised at the start, in dollars.
GOALscript.js2000The fund’s goal, in dollars.
INKscript.js#0a0a0aThe colour of the button and the bar.
ACCENTscript.js#2f8f5bThe green of the button when it thanks you and of the new part of the bar.
LEAFscript.js#3da56bThe green of the trees’ crowns.

Try them in the Playground

When to use it

For the «Donate» button on the site of a charity, a fundraiser or an environmental project: whoever gives picks the amount without leaving the page and sees straight away what the gift has done.

On phones

On the phone the amounts open by tapping the button and close by tapping outside; the pills are 34 pixels tall and the fan fits within 182 pixels, so it fits even in the narrowest box.

With reduced motion

The amounts fade in in place, the chosen one fades without dropping, the button turns green and changes its label without sliding, the trees fade in and out without swaying, the amount raised changes at once and the drawn pointer is not shown.

Pitfalls

  • Each tree has its own translate attribute: GSAP animates only the groups inside (shadow, trunk, crown, body) with svgOrigin at the base, otherwise its transform would wipe out the tree’s place.
  • The pills are visibility hidden when closed: merely transparent, they would stay clickable and the Tab key would reach them.
  • On devices without hover the opening goes through the tap on the button: the finger’s pointerenter would arrive with the click and the fan would open and close at once.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 30 October 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