Skip to content
animorio
IT
All components

Weight tracker

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

The weight log of a health app, in a card on black: today’s value, large, to nudge with minus and plus, and below it the week’s curve with the goal line. At every tap the number changes at once and the last point of the curve follows on a spring, pulling the line with it; at the top the change over the week rolls, its arrow turning. “Save today” pins the point, which fills in, and draws the tick.

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>
<!--
  "Weight tracker" 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>Weight tracker</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">
    <!-- a weight log: today's value nudged with minus and plus, the last point of the week's curve following on a
         spring, the change over the week rolling at the top, and Save pinning the point down -->
    <section class="wt" data-wt aria-label="Weight tracker">
      <header class="wt__head">
        <strong>Weight</strong>
        <span class="wt__delta" data-delta><svg viewBox="0 0 12 12" aria-hidden="true"><path data-arrow d="M6 2.200v7.600M2.800 6.600 6 9.800l3.200-3.200"></path></svg><span class="wt__clip"><span data-outdelta>0.6 kg this week</span></span></span>
      </header>

      <div class="wt__set">
        <button type="button" class="wt__step" data-step="-1" aria-label="A little less"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.500 8h9"></path></svg></button>
        <p class="wt__now" aria-live="off"><b data-outvalue>72.8</b><i data-outunit>kg</i></p>
        <button type="button" class="wt__step" data-step="1" aria-label="A little more"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.500 8h9M8 3.500v9"></path></svg></button>
      </div>

      <div class="wt__chart" data-chart>
        <svg viewBox="0 0 300 92" aria-hidden="true" preserveAspectRatio="none">
          <defs><linearGradient id="wt-fade" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="currentColor" stop-opacity="0.22"></stop><stop offset="1" stop-color="currentColor" stop-opacity="0"></stop></linearGradient></defs>
          <line class="wt__goal" data-goal x1="0" y1="60" x2="300" y2="60"></line>
          <path class="wt__area" data-area d=""></path>
          <path class="wt__line" data-line d=""></path>
          <line class="wt__guide" data-guide x1="0" y1="0" x2="0" y2="92"></line>
        </svg>
        <i class="wt__dot" data-dot aria-hidden="true"></i>
        <span class="wt__goaltag" data-goaltag aria-hidden="true">Goal 72</span>
        <span class="wt__tip" data-tip aria-hidden="true"></span>
      </div>
      <ol class="wt__days" aria-hidden="true"><li>Wed</li><li>Thu</li><li>Fri</li><li>Sat</li><li>Sun</li><li>Mon</li><li class="is-today">Today</li></ol>

      <button type="button" class="wt__save" data-save><svg viewBox="0 0 16 16" aria-hidden="true"><path pathLength="1" d="M3.400 8.400 6.600 11.500 12.700 4.800"></path></svg><span class="wt__clip"><span data-outsave>Save today</span></span></button>
    </section>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

24 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 “Weight tracker” 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 black, a dark rounded card: “Weight” and on the right a pill with an orange arrow pointing down and “0.6 kg this week”. In the middle, between two round buttons with minus and plus, today’s value: “72.8 kg”. Below, the orange curve of the seven days, from “Wed” to “Today”, with a fade falling under it and an empty circle on the last point; a dashed line crosses the chart with the tag “Goal 72”. At the bottom the light button “Save today”. On entering the curve draws itself from the left and the circle lands on its tip. Tapping minus takes the number down a tenth with a small kick, and the circle moves down the curve, just overshooting the right spot before settling, the line following it; the pill rolls into “0.7 kg this week”. Holding keeps the value going down, faster and faster. Going below the goal turns the tag into “Goal reached”. Pointing at the chart brings a vertical line and that day’s value, “Fri 73.1”. Tapping “Save today” fills the circle with a bounce, the tick draws itself on the button and the label becomes “Saved”; nudging the value again makes it unsaved.

How it works

Two speeds

The number goes to its new value in an instant; the point on the curve gets there on a spring. They are two tweens on the same object, one for the written number and one for the point.

The curve redrawn

At every frame of the spring the path is rewritten: a smooth curve through the seven points, its handles taken from the neighbouring points.

A drawing that stretches, marks that do not

The chart stretches with the card; the circle, the goal tag and the pointed value are HTML elements placed on top in percentages, so they stay round and readable.

Saving

Saving fills the circle and draws the tick; any nudge afterwards takes the button back to “Save today”.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#ff8a4cThe colour of the curve.
TODAYscript.js72.8The weight proposed for today, the same as yesterday.
GOALscript.js72The goal, the dashed line.
UNITscript.jskgThe unit written beside the number.
SPRINGscript.js1How much today’s point bounces when you change the value.
LOOPscript.jstrueLeft alone, the demo’s pointer lowers the value, looks at a day and saves.

Try them in the Playground

When to use it

In the app of a smart scale, a nutritionist, a gym or a training programme; the same card carries any measure logged daily and watched over time: blood pressure, hours of sleep, glucose, kilometres.

On phones

The card is at most 348 pixels wide and about 320 tall; the chart gets shorter on short screens. The two round buttons are 44 pixels and can be held down; on the chart a tap shows the nearest day.

With reduced motion

No springs and no curve drawing itself: number, point, curve and texts are at the new value at once. The demo’s pointer does not start.

Pitfalls

  • The change is not just a coloured arrow: it says the number, and screen reader users hear “Down 0.6 kg this week” on saving.
  • Going down is not always good: the demo passes no judgement and gives no reward colours, apart from the tag of the goal the user chose.
  • The svg is stretched in width: strokes have vector-effect: non-scaling-stroke, otherwise the line thickens or thins with the card.
  • The value has a minimum and a maximum close to the data, so the point never leaves the chart.
  • Weights, days and goal are invented.

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