Skip to content
animorio
IT
All components

Plant a tree button

Buttons, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 8.2 KBGSAP 28 KBFreeDownload the zip

The «Plant a tree» button of an invented climate app, Rootwell, in near-black green lacquer on white, like a Dribbble shot: the cream knob holds a little window onto the soil, seen in cross-section, with a seed resting on top. On tap the seed hops and drops into the soil kicking up a little dust, roots reach down below, the sprout pushes up above bent like a hook, straightens and opens two leaves on a spring, then a bud; forest green fills the pill from the knob, it says Tree planted, and the trees planted counter rolls up by one, digit by digit, while the goal line moves on. The sprout sways in the breeze, then bows back into the soil and a new seed falls in.

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>
<!--
  "Plant a tree 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 Plant a tree button with the sprout growing in the pill</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 climate app: tap the pill, the seed drops into the soil window of the knob,
         roots reach down, the sprout pushes up as a hook, straightens and opens two leaves,
         the pill turns forest green and the trees counter rolls up by one -->
    <div class="plot" data-plot>
      <p class="plot__top">
        <span class="plot__brand">Rootwell</span>
        <span class="plot__where">Alder Ridge · native oak</span>
      </p>

      <button class="plant" type="button" data-plant data-autoclic aria-pressed="false">
        <span class="plant__green" data-green aria-hidden="true"></span>
        <span class="plant__sheen" data-sheen aria-hidden="true"></span>
        <span class="plant__knob" data-knob aria-hidden="true">
          <svg class="pot" viewBox="0 0 48 48">
            <defs>
              <clipPath id="tondo"><circle cx="24" cy="24" r="24"/></clipPath>
              <clipPath id="sotto"><rect x="0" y="32.6" width="48" height="16"/></clipPath>
              <linearGradient id="terra" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0" stop-color="#7a5536"/>
                <stop offset="0.45" stop-color="#5b3d25"/>
                <stop offset="1" stop-color="#3a2717"/>
              </linearGradient>
              <linearGradient id="foglia-s" x1="1" y1="0" x2="0" y2="1">
                <stop offset="0" stop-color="#9be08a"/>
                <stop offset="0.55" stop-color="#4fb35e"/>
                <stop offset="1" stop-color="#2d7f43"/>
              </linearGradient>
              <linearGradient id="foglia-d" x1="0" y1="0" x2="1" y2="1">
                <stop offset="0" stop-color="#a8e892"/>
                <stop offset="0.5" stop-color="#58bd63"/>
                <stop offset="1" stop-color="#2f8546"/>
              </linearGradient>
              <radialGradient id="seme" cx="0.35" cy="0.3" r="0.8">
                <stop offset="0" stop-color="#e9c48e"/>
                <stop offset="0.6" stop-color="#b9864d"/>
                <stop offset="1" stop-color="#7b5228"/>
              </radialGradient>
            </defs>
            <g clip-path="url(#tondo)">
              <g data-soil>
                <path class="soil" d="M-2 33.4C8 32.2 16 33.6 24 33 32 32.4 40 33.6 50 32.8V50H-2Z"/>
                <path class="soil__edge" d="M-2 33.4C8 32.2 16 33.6 24 33 32 32.4 40 33.6 50 32.8"/>
                <g class="soil__grit">
                  <ellipse cx="9" cy="38.5" rx="1.3" ry=".8"/>
                  <ellipse cx="36.5" cy="41" rx="1.6" ry=".9"/>
                  <ellipse cx="17" cy="44" rx="1" ry=".6"/>
                  <ellipse cx="31" cy="36.6" rx=".8" ry=".5"/>
                  <ellipse cx="41" cy="36" rx=".7" ry=".45"/>
                </g>
                <g clip-path="url(#sotto)">
                  <path class="root" data-root d="M24 36.6C23.4 39.4 21.6 41.2 19.8 44.6"/>
                  <path class="root" data-root d="M24.3 36.8C25.4 39.8 27.6 41.4 28.6 45.4"/>
                  <path class="root root--fine" data-root d="M24 37C24.2 40.2 23.6 43 24.4 47"/>
                  <path class="root root--fine" data-root d="M21.6 41.6C20.4 41.8 18.8 41.4 17.6 42.2"/>
                </g>
              </g>
              <path class="stem" data-stem d="M24 35.6"/>
              <g data-leaves>
                <g data-leaf-l>
                  <path class="leaf" fill="url(#foglia-s)" d="M0 0C-2.6-.6-6.6-.2-9.2 2.2-6.6 4.6-2.6 3.6 0 0Z"/>
                  <path class="leaf__rib" d="M0 0C-3 1-5.6 1.6-8 2.2"/>
                </g>
                <g data-leaf-r>
                  <path class="leaf" fill="url(#foglia-d)" d="M0 0C2.4-1.4 6.2-2.6 9.6-1.2 8-1.6 3.6 3.4 0 0Z"/>
                  <path class="leaf__rib" d="M0 0C3-.8 5.8-1.2 8.6-1.1"/>
                </g>
                <g data-bud><path class="bud" d="M0 0C-.8-1.2-.6-2.6.4-3.4 1.2-2.4 1-1 0 0Z"/></g>
              </g>
              <g data-seed>
                <ellipse class="seed" cx="0" cy="0" rx="2.9" ry="2.1" fill="url(#seme)"/>
                <path class="seed__line" d="M-1.8-.5C-.6-1.2.9-1.2 2-.4"/>
              </g>
              <g class="dust" data-dust>
                <circle cx="24" cy="33" r=".55"/><circle cx="24" cy="33" r=".45"/><circle cx="24" cy="33" r=".5"/><circle cx="24" cy="33" r=".4"/><circle cx="24" cy="33" r=".45"/>
              </g>
            </g>
            <circle class="pot__rim" cx="24" cy="24" r="23.4"/>
          </svg>
        </span>
        <span class="plant__words">
          <span class="plant__label" data-idle>Plant a tree</span>
          <span class="plant__label plant__label--on" data-on aria-hidden="true">Tree planted</span>
        </span>
        <span class="plant__price" data-price aria-hidden="true">$1</span>
      </button>

      <div class="plot__count">
        <p class="tally" aria-live="polite">
          <span class="tally__num" data-num aria-label="12,480"></span>
          <span class="tally__word">trees planted</span>
          <span class="tally__plus" data-plus aria-hidden="true">+1</span>
        </p>
        <span class="goal" aria-hidden="true"><span class="goal__bar" data-bar></span></span>
        <span class="tally__goal">Goal <span data-goal>15,000</span></span>
      </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.

21 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 “Plant a tree 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 the line «Rootwell» with «Alder Ridge · native oak», below it a 60-pixel pill of near-black green lacquer, with a soft light at the top, a fine grain and a three-layer shadow; on the left the cream knob, then «Plant a tree» and on the right the price «$1» in a small glass capsule. The knob shows the soil in cross-section: the wavy surface with its light edge, the soil darkening towards the bottom, a few pebbles, and on top a glossy seed with its line. Under the pill there is «12,480 trees planted», on the right «Goal 15,000» and below a thin line showing how far there is to go. Hovering makes the seed rock on the soil, lifts the knob one pixel and runs a light over the lacquer. On tap the pill gives, the knob squeezes and comes back on a spring, the seed hops, spins and drops into the soil, where it stays visible in the cross-section; the soil jolts and five grains of dust jump off. Below the seed the roots draw themselves one after the other, above it the sprout comes out bent like a hook as real ones do, stretches, straightens with a small bounce and opens two leaves that unfold on a spring, then a bud appears in the middle. Meanwhile forest green spreads from the knob and fills the pill, a light crosses it, the price withdraws and «Plant a tree» gives way to «Tree planted». The counter rolls up by one, only the digits that change, with a small green «+1» beside it, and the goal line moves on. The sprout sways in the breeze; after a moment it folds its leaves, bows back into the soil, the roots withdraw, the green returns into the knob and a new seed falls from above and bounces on the soil. A drawn pointer plants one tree after another by itself; at the first real touch it steps aside.

How it works

The soil in cross-section

The knob is a 48-unit SVG cut by a round clipPath: inside there is the soil with a vertical gradient from warm brown to near black, the wavy surface with a lighter thread and five pebbles. The roots sit in a second clipPath that starts under the surface, so they never show above the soil, and they draw themselves with stroke-dashoffset, each a little after the one before.

The sprout redrawn every frame

The stem is not a fixed path: it is an object of numbers (how far it has grown, how bent the hook is, how much it sways) and a draw() function that rewrites the d attribute on every update, with two Bézier curves: the stem and the hook on top. GSAP only animates those numbers; the hook opens as growth reaches the end with back.out, and that is where the plant feels alive.

Leaves on a spring

The two leaves sit in a group that draw() carries to the stem’s tip with translate and rotate; each has its own scale and fold (58 degrees closed, zero open), written into the transform attribute. The scale arrives with back.out, the fold with elastic.out: they open a little too far and come back, like real leaves stretching out.

The rolling counter

Each digit of the counter is a column from 0 to 9 inside a window one line tall; it moves with yPercent of minus ten times the digit. On a new tree only the columns that change roll, from the right, staggered by seven hundredths; if the number changes length the columns are rebuilt. The thousands comma is a separate element that does not roll.

The breeze

Once the tree is planted a single GSAP ticker listener adds two sines of different frequencies into the sway: the stem’s tip moves and the leaves turn with it. The amplitude rises over eight tenths of a second, so the breeze never starts abruptly, and the ticker is removed when the sprout goes back in.

Values to change

NameFileDefaultWhat it changes
GROWscript.js1.4How long the sprout takes to grow from the seed to its two leaves, in seconds.
HOLDscript.js2.4How many seconds «Tree planted» stays before a new seed arrives.
TREESscript.js12480The trees already planted, where the counter starts.
GOALscript.js15000The campaign goal, for the line under the counter.
INKscript.js#0e1a14The colour of the pill before planting.
FORESTscript.js#1d6b40The forest green that fills the pill once the tree is planted.

Try them in the Playground

When to use it

For the main button of a climate app or site, a reforestation fundraiser, a shop that plants a tree with every order, or any action that makes something grow: the sprout tells you what happened and the counter tells you it matters.

On phones

On the phone the pill adapts to the width (at most 340 pixels, with a 16-pixel margin) and stays 60 tall; the sprout lives entirely in the knob, so nothing changes. There is no hover, everything else is the same.

With reduced motion

The seed goes straight into the soil, the sprout with open leaves fades in without growing or swaying, the green spreads without a spring, the counter digits change without rolling and the drawn pointer is not shown.

Pitfalls

  • GSAP transforms on the leaves, inside a group moved by its transform attribute, turned around the wrong point: leaves, stem and seed are all written by hand in draw(), and GSAP only animates the numbers.
  • Roots in the same clip as the stem poked above the surface when the soil jolts: they have their own clipPath that starts below the soil line.
  • With the breeze on, the timeline and the ticker redrew twice a frame: while the ticker runs the timeline does not call draw().

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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