Skip to content
animorio
IT
Back to the library

Energy bill breakdown

SVG, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.3 KBGSAP 28 KBFreeDownload the zip

The bill card in an energy provider’s app: the total counts up to 86.40 euros above one solid orange bar, then the bar cuts itself into four pieces (energy, network, taxes, VAT) and the items arrive one after the other with their amounts. Pointing at an item, its piece lifts, the others dim and the total becomes its share.

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>
<!--
  "Energy bill breakdown" 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 month's energy bill that breaks down into its items</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 bill card of an energy provider's app: one solid bar and the total; then the bar cuts itself into
         its items (energy, network, taxes, VAT) and the rows arrive one by one with their amounts counting.
         Pointing at a row or a segment lifts that piece, dims the others and rolls the total to its share -->
    <article class="card" data-card>
      <header class="head">
        <div class="head__text">
          <p class="head__eyebrow"><span data-eyebrow>November bill</span></p>
          <p class="head__total"><span data-total>€86.40</span></p>
        </div>
        <p class="head__chip"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9.2 1.8 3.8 9h3.6l-.8 5.2L12.2 7H8.4Z"></path></svg><span>312 kWh</span></p>
      </header>

      <svg class="bar" data-bar viewBox="0 0 300 16" preserveAspectRatio="none" aria-hidden="true"></svg>

      <ul class="rows" data-rows></ul>
    </article>

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

16 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 “Energy bill breakdown” 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 paper-coloured background, a white card: at the top “November bill”, below it the big total counting from zero to €86.40, on the right a tag with the bolt and 312 kWh. Below, one solid orange bar grows from the left. Then the bar cuts itself: from left to right the gaps open, each piece takes its own shade (from full to very light) with a small hop, and the rows arrive underneath: Energy used, Network & meter, Taxes, VAT, each with its little square, the percentage and the amount counting. Pointing at a row or at a piece of the bar, that piece lifts and lights up, the others fade, the row takes a warm background and at the top the total rolls to that item’s amount with how much it weighs on the bill. Leaving, the total comes back.

How it works

The bar

An SVG with one rectangle per item, as wide as its share of the total. When joined, the rectangles overlap by 6 units and all have the full colour, so no seams show; at the cut GSAP animates the x and width attributes (attr) to open GAP-wide spaces and the opacity to give each piece its shade.

The items

The rows start 10 pixels lower and transparent, and arrive staggered by STAGGER seconds together with their piece; each amount counts from zero with a tween on a number.

The hover

One function, pick(i): it lifts and enlarges the chosen piece from the bottom (transform-origin at the bottom), takes the others to 30%, puts the class on the row and rolls total and eyebrow. Rows, bar pieces, keyboard focus and the drawn pointer all call it.

Values to change

NameFileDefaultWhat it changes
MONTHscript.jsNovember billThe line above the total.
ITEMSscript.jsEnergy used:41.20, Network & meter:21.60, Taxes:15.70, VAT:7.90The bill’s items: name:amount, separated by commas (up to five).
CURRENCYscript.js€The currency symbol.
ACCENTscript.js#f0731fThe colour of the bar.
GAPscript.js3The space between segments when the bar cuts.
STAGGERscript.js0.09The seconds between one item and the next.
RESTscript.js1.1On its own: how long it stops on each item.
LOOPscript.jstrueLeft alone, a pointer goes over the items.

Try them in the Playground

When to use it

For the customer area of a power and gas provider, a smart home app, a spending or subscriptions dashboard: wherever a total has to be explained piece by piece. The items change in one line; total and percentages work themselves out.

On phones

The same card, as wide as the screen minus the margins and with slightly lower rows. With no pointer, tap an item to choose it and tap it again to go back to the total.

With reduced motion

The bar is already cut and the items already in place, they fade in. On hover only opacities and numbers change, with no pieces lifting.

Pitfalls

  • The widths of the pieces are animated as SVG attributes (attr), not with scaleX: scaling would squash the rounded corners.
  • The bar has preserveAspectRatio none to fill the card: it works because the viewBox (300 by 16) is almost the real size; much wider and the corners would distort.
  • The amounts are made-up numbers: in a real product they come from the server already rounded, and the items must add up to the total to the cent.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 15 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 animations