Skip to content
animorio
IT
All components

Battery health card

Cards, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.4 KBGSAP 28 KBFreeDownload the zip

The Battery health page in the settings of Lumo One, a made-up phone: the drawn battery fills up to 87% of the capacity it had when new, the surface of the charge swaying and settling, the figure rolling, «Normal» for peak performance, the 412 charge cycles counting up, the capacity curve of the last twelve months drawing itself to today’s point. Then Optimized charging switches on with a spring and the line «Charging will pause at 80%» opens below, the stop mark sliding along the bar to 80%. On white, with a single green.

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>
<!--
  "Battery health 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>Battery health card</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 Battery health page in the settings of Lumo One, a made-up phone: the battery fills up to its
         maximum capacity, the cycles count up, twelve months of capacity draw themselves, and Optimized
         charging switches on and moves the stop mark to 80% -->
    <section class="card" data-card aria-label="Battery health, Lumo One">
      <span class="card__edge" aria-hidden="true"></span>

      <header class="head">
        <span class="back" aria-hidden="true">
          <svg viewBox="0 0 20 20"><path d="M12.2 4.6 6.8 10l5.4 5.4"/></svg>
        </span>
        <div class="head__txt">
          <h1 class="head__title">Battery health</h1>
          <p class="head__sub">Lumo One · Settings</p>
        </div>
      </header>

      <div class="hero">
        <div class="cell" data-cell aria-hidden="true">
          <span class="cell__body">
            <span class="cell__fill" data-fill>
              <svg class="cell__wave" data-wave viewBox="0 0 12 100" preserveAspectRatio="none"><defs><linearGradient id="carica" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#2bc184"/><stop offset=".6" stop-color="#14a36b"/><stop offset="1" stop-color="#11915f"/></linearGradient></defs><path fill="url(#carica)" data-wave-path d="M0 0 L6 0 L6 100 L0 100 Z"/></svg>
              <span class="cell__shine"></span>
            </span>
            <span class="cell__mark" data-cap-mark></span>
          </span>
          <span class="cell__tip"></span>
        </div>
        <div class="hero__txt">
          <p class="big"><span class="roll" data-roll="cap">0</span><span class="big__pct">%</span></p>
          <p class="hero__lab">Maximum capacity</p>
        </div>
      </div>

      <dl class="rows">
        <div class="row">
          <dt>Peak performance</dt>
          <dd><span class="tag" data-tag>Normal</span></dd>
        </div>
        <div class="row">
          <dt>Charge cycles</dt>
          <dd><span class="roll" data-roll="cycles">000</span></dd>
        </div>
      </dl>

      <figure class="trend">
        <figcaption class="trend__head"><span>Capacity, last 12 months</span><span class="trend__now" data-now>Today</span></figcaption>
        <svg class="trend__svg" data-trend viewBox="0 0 240 40" preserveAspectRatio="none" aria-hidden="true">
          <line class="trend__base" x1="0" y1="39.5" x2="240" y2="39.5"/>
          <path class="trend__area" data-area d=""/>
          <path class="trend__line" data-line d="" pathLength="1"/>
        </svg>
        <span class="trend__pin" data-pin aria-hidden="true"><span class="trend__pin-in"></span></span>
      </figure>

      <div class="opt">
        <div class="opt__top">
          <div class="opt__txt">
            <p class="opt__title">Optimized charging</p>
            <p class="opt__sub">Learns your routine to slow ageing</p>
          </div>
          <button class="switch" type="button" role="switch" aria-checked="false" data-switch aria-label="Optimized charging">
            <span class="switch__knob" data-knob></span>
          </button>
        </div>
        <div class="limit" data-limit aria-hidden="true">
          <div class="limit__in">
            <p class="limit__lab">Charging will pause at <strong>80%</strong></p>
            <div class="bar">
              <span class="bar__track"><span class="bar__fill" data-bar-fill></span></span>
              <span class="bar__stop" data-stop><span class="bar__stop-line"></span></span>
            </div>
          </div>
        </div>
      </div>
    </section>
  </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.

32 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Battery health 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

The card rises and the battery fills from the left: the charge goes a hair past 87% and back while its surface sways and calms down; the big figure rolls up to 87, the left digits landing first, and a dashed line marks where the new battery reached. «Normal» comes in with a small bounce, the cycles count up to 412, the capacity curve of the last twelve months draws itself and fills with a light green underneath, and today’s point lights up. Then the Optimized charging switch turns on: the knob stretches, sets off and lands on a spring; below, «Charging will pause at 80%» opens, the bar fills and the black mark slides to 80%. After a pause the switch turns off, the line closes and the demo starts over. The switch can be tapped at any moment.

How it works

The surface of the charge

At the right end of the fill sits a narrow SVG whose path is rebuilt every frame: a sine wave whose amplitude starts high and drops to zero in a little more than the fill time. It stops on its own, so at rest it costs nothing.

Digits like an odometer

Each digit is a column from 0 to 9 in a window one line tall; the left columns roll less and land first, with a back.out taking each one a pixel past. Leading zeros are hidden, so 087 reads 87.

The stretching knob

When the switch changes, the knob widens by a quarter before it sets off and turns round again as it lands on a spring: the gesture of real phone switches. The line that opens below grows to the measured height of its content, recalculated on resize.

Values to change

NameFileDefaultWhat it changes
CAPACITYscript.js87The maximum capacity left, in percent of when the phone was new.
CYCLESscript.js412The charge cycles counted so far.
PAUSE_ATscript.js80Where Optimized charging stops the charge, in percent.
FILL_TIMEscript.js1.6Seconds the battery takes to fill up to its capacity.
WAVEscript.js1How much the surface of the charge sways before it settles (0 = still).
SPRINGscript.js0.5How springy the switch and the stop mark are (lower = more bounce).
DRAW_TIMEscript.js1.3Seconds the twelve months of capacity take to draw.
HOLDscript.js2.4Seconds the finished card stays before the demo starts over.

Try them in the Playground

When to use it

In the settings of an app or a phone, in product pages for things with a battery (headphones, electric cars, bikes, laptops) and in device dashboards: it says at a glance how the battery is doing and what can be done to make it last.

On phones

Everything is in em and the size depends on both the width and the height of the window, so the whole card fits the phone box. The switch is big enough for a thumb.

With reduced motion

No springs or waves: the card arrives finished, the battery at 87%, the figures in place, the curve drawn and Optimized charging already on; the switch changes without bounces.

Pitfalls

  • Today’s point sits outside the SVG (which is stretched with preserveAspectRatio none, and a circle inside would turn into an oval): its position is recalculated from the path and the SVG size on resize.
  • A line that opens with height must be measured on its inner content, not on itself: closed, it is zero tall.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 1 December 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