Skip to content
animorio
IT
All components

Carbon offset button

Buttons, Hover, SVG, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 9.7 KBGSAP 28 KBFreeDownload the zip

The Offset shipping button in the checkout of Fernwell, a made-up online shop: a white pill with a one pixel edge that catches the light, a small grey CO2 cloud drawn in line, 1.8 kg CO2e under the label and the +$0.42 cost sunk into a notch. Pressed, the cloud breaks into specks that rise like smoke, turn green and gather again as a leaf that rights itself on a spring; the label rolls to Offset added, a tick draws in the notch as it turns green and the cost flies on an arc into the order total, which rolls up. Another tap takes it back with the same gesture in reverse.

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>
<!--
  "Carbon offset 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>Carbon offset button</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">
    <!-- one gesture: offset the shipping. Pressed, the grey cloud of CO2 inside the pill breaks into specks that
         drift up and gather again as a green leaf, the label rolls to Offset added, a tick draws in the chip and the
         cost flies down into the order total, which rolls up. Another press takes the offset back the other way -->
    <div class="frame" data-wrap>
      <button class="s" type="button" data-btn data-autoclic aria-pressed="false" aria-describedby="s-note">
        <span class="s__shadow" data-shadow aria-hidden="true"></span>
        <span class="s__shell" data-shell aria-hidden="true">
          <span class="s__skin"></span>
          <span class="s__fill" data-fill></span>
          <span class="s__glow" data-glow></span>
          <span class="s__sheen" data-sheen></span>
          <span class="s__edge"></span>
          <span class="s__edge s__edge--on" data-edge></span>
        </span>

        <span class="s__icon" aria-hidden="true">
          <svg viewBox="0 0 24 24" data-svg>
            <g data-cloud>
              <g data-breath>
                <path class="cloud__body" data-cloud-path d="M7 18.5h10a4 4 0 0 0 .6-7.95a5.5 5.5 0 0 0-10.5 1.2A3.4 3.4 0 0 0 7 18.5Z"></path>
                <path class="cloud__line" d="M9.4 15.4h5.4"></path>
              </g>
            </g>
            <g data-leaf>
              <path class="leaf__body" data-leaf-path d="M5.6 18.4C5.6 10.6 10.8 5.6 18.8 5.6C18.8 13.4 13.8 18.4 5.6 18.4Z"></path>
              <path class="leaf__vein" data-vein d="M5.6 18.4L12.6 11.4M9.6 14.4h3.4M11.6 12.4V9.2"></path>
              <path class="leaf__stem" data-stem d="M5.6 18.4L3.8 20.2"></path>
            </g>
            <g data-dust></g>
          </svg>
        </span>

        <span class="s__text">
          <span class="s__labels" data-labels>
            <span class="s__label" data-l="idle">Offset shipping</span>
            <span class="s__label" data-l="done">Offset added</span>
          </span>
          <span class="s__sub" data-sub><span data-kg>1.8</span> kg CO<sub>2</sub>e</span>
        </span>

        <span class="s__chip" data-chip aria-hidden="true">
          <span class="chip__skin"></span>
          <span class="chip__skin chip__skin--on" data-chipon></span>
          <span class="chip__price" data-price>+$0.42</span>
          <svg class="chip__check" viewBox="0 0 24 24"><path data-tick d="M6.6 12.4l3.6 3.5 7.2-7.6"></path></svg>
        </span>
      </button>

      <p class="note" id="s-note" aria-live="polite">
        <span class="note__k">Fernwell order total</span>
        <span class="note__total odo" data-odo="total"></span>
      </p>

      <span class="token" data-token aria-hidden="true">
        <span class="token__skin"></span>
        <span class="token__txt" data-token-txt>+$0.42</span>
      </span>

      <span class="sr" data-sr></span>
    </div>
  </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 “Carbon offset 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 ground sits the white Offset shipping pill, with a soft layered shadow carrying a thread of green and a one pixel edge, darker at the bottom and light at the top, that catches the light. On the left, free inside the pill, a small grey CO2 cloud drawn in line with a stroke inside it; in the middle the label and under it, small and grey, 1.8 kg CO2e; on the right the +$0.42 cost sunk into a grey notch. Under the pill the Fernwell order total line with the $86.40 total. On hover the cloud breathes, swelling and lifting by a hair, a very pale green light follows the pointer, the pill widens by a few pixels with a bounce and the label widens on the font’s wdth axis. Pressed, the pill sinks one pixel and squashes one pixel, and its shadow tightens; let go it springs back. On the tap the cloud breaks into twenty two specks that spread and rise like smoke, turn from grey to green and settle one after another on the outline of a leaf; the leaf draws itself, fills with a green veil, grows its stem and veins and rights itself on a spring. Meanwhile the label rolls to Offset added in dark green, the cost lifts out of the notch as a small green +$0.42 token and drops in an arc onto the total, where it squashes and vanishes while the total dips by two pixels and its digits roll up to $86.82; the notch turns green and a white tick draws in it, pale green spreads over the pill from the leaf, the edge takes a green tint, the pill swells a hair and a light crosses it. Another tap does it all in reverse: the leaf comes apart into green specks that turn grey and become the cloud again, the cost flies back into the notch and the total returns to $86.40.

How it works

Two shapes and the same specks

The cloud and the leaf are two SVG paths. On start getPointAtLength takes twenty two points along each (the leaf’s shifted by a third, so the specks cross the shape instead of sliding round the edge) and a circle is made for each pair. The change is a timeline: the starting shape shrinks and fades, every speck grows, moves away from the middle and rises by DRIFT with a random delay, changes colour, then goes to its landing point with a back.out, eleven thousandths apart.

The leaf that draws and rights itself

Outline, stem and veins have a stroke-dasharray as long as the path: GSAP brings the stroke-dashoffset to zero as the specks arrive, and the green veil comes in with fill-opacity. The leaf group starts fourteen degrees off and a little smaller and rights itself with an elastic.out round a fixed svgOrigin, so it passes by a degree and comes back.

The cost that flies into the total

The token lives outside the button, in the component’s frame: the script measures the middle of the price and of the total and a 0 to 1 tween carries it along a quadratic Bézier curve with its control point above both ends, tilted by the sine of the path. When it lands it squashes and vanishes, and the digits of the total, columns of 0 to 9 moved with yPercent, roll from the right with a back.out.

Press, breath and light

The press lowers the button by one pixel and squashes it by one pixel (scaleY 0.983) and dims the shadow layer, which sits on its own under the shell. On hover an inner group of the cloud breathes on an endless sine.inOut timeline, separate from the group that breaks up, so the two animations do not cancel each other. The pale green of the added state is a circle clip-path in pixels starting from the leaf, worked out again on every resize.

Values to change

NameFileDefaultWhat it changes
COSTscript.js0.42What offsetting the shipping costs, in dollars.
TOTALscript.js86.4The order total before the offset.
KGscript.js1.8The kilos of CO2 offset, written under the label.
SPECKSscript.js22How many specks the cloud breaks into.
MORPHscript.js1.15The seconds of the change from cloud to leaf.
DRIFTscript.js3.2How far the specks rise as the cloud breaks up.
ARCscript.js30How high the cost’s arc rises before dropping into the total, in pixels.
BOUNCEscript.js1.5How much the pill, the digits and the cloud bounce.
SKIPscript.js1For how many clicks of the self-running round the added offset stays in view before it is taken back.
--verdestyle.css#1f8a57The green of the leaf, the notch and the specks.
--nuvolastyle.css#a9aeb2The grey of the CO2 cloud.

Try them in the Playground

When to use it

In the checkout or cart of an online shop that offers to offset the shipping emissions: the shopper sees in one gesture what they add, what it costs and where the price lands in the total.

On phones

The pill drops to 58 pixels, the label by half a point and the notch to 38; the finger taps like the mouse and the press looks the same. Without hover the cloud does not breathe and the light stays off; the rest is the same.

With reduced motion

No specks, flight or rolling: the cloud fades out and the leaf fades in already drawn, the label, the tick, the green of the pill and the digits of the total change with a fade; on the way back the same in reverse.

Pitfalls

  • The hover breath and the breaking cloud both write the transform: the breath lives on an inner group (data-breath), the break on the outer one, or they cancel each other.
  • Leaf points taken from the same start as the cloud’s made the specks slide along the edge: shifted by a third of the way round, they cross the shape and you can see it become another.
  • The autopilot clicks every 2.8 seconds and took the offset away as soon as the leaf had righted itself; a limit in seconds was not enough, because the preview video runs time its own way: now the button skips SKIP of the pilot’s clicks (only the untrusted ones, isTrusted false) before going back.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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