Skip to content
animorio
IT
Back to the library

Macro tracker

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

The day’s macros in a food app: the calorie ring, the three bars for protein, carbs and fat and four meals to add. Tap a meal and its plus becomes a tick, the ring grows while the calories count and the bars lengthen one after the other with a bounce. Hover a bar and the numbers roll into what is left to the goal.

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>
<!--
  "Macro 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>Macro 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">
    <!-- the day's macros in a food app: add a meal and the calorie ring and the three bars grow on springs
         while the numbers count; hover a bar to read what is left -->
    <section class="mt" data-mt aria-label="Today's macros">
      <header class="mt__head"><h2>Today</h2><span>Goal <b data-goal></b> kcal</span></header>
      <div class="mt__body">
        <div class="mt__ring">
          <svg viewBox="0 0 104 104" aria-hidden="true"><circle class="mt__track" cx="52" cy="52" r="44"></circle><circle class="mt__arc" data-arc pathLength="1" cx="52" cy="52" r="44" transform="rotate(-90 52 52)"></circle><circle class="mt__over" data-over pathLength="1" cx="52" cy="52" r="44" transform="rotate(-90 52 52)"></circle></svg>
          <div class="mt__kcal"><b data-kcal></b><span data-kcalsub>kcal eaten</span></div>
        </div>
        <ul class="mt__bars" data-bars></ul>
      </div>
      <div class="mt__meals" data-meals role="group" aria-label="Meals"></div>
      <span class="mt__say" data-say aria-live="polite"></span>
    </section>

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

17 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 “Macro 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 a pale ground with a green glow at the top, a white card: “Today” and “Goal 2,100 kcal”. On the left a green ring holding “420 kcal eaten”; on the right three rows, Protein, Carbs and Fat, each with grams eaten over the goal and a bar in its colour, orange, yellow and blue. Below, four meals two by two: Oat bowl, already chosen with a green tick, then Wrap, Yogurt and Salmon with a plus and their calories. Tap Wrap and the button gives, the plus turns into a tick, the edge goes green; the ring advances while the number counts to 930 with a small jump, and the three bars lengthen one after the other, just overshooting. With the pointer on Protein the bar thickens and on the right “52 / 140 g” rolls into “88 g to go”. Another tap on a meal removes it and everything goes back. Past the goal the ring makes a second, darker lap and under the number appears how far over it is.

How it works

One object, four numbers

Calories, protein, carbs and fat as shown live in one object; at each tap the chosen meals are summed again and four tweens take it there.

Staggered bars

Calories arrive on a soft curve, the three macros on an elastic six hundredths apart: the bars lengthen in a row.

The ring

An SVG circle with pathLength 1 and stroke-dashoffset equal to one minus the share of the goal; a second circle on top shows the excess.

What is left

Over a bar a variable says the remainder is wanted: the same function that writes the grams then writes “88 g to go”, and the text rolls.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2fb573The colour of the calorie ring and the chosen meals.
GOALscript.js2100The day’s calorie goal.
FILL_TIMEscript.js0.9How many seconds the ring and the bars take to reach the new value.
SPRINGscript.js1How much the bars and the meal’s tick bounce: 0.3 = a little, 2 = a lot.
LOOPscript.jstrueLeft alone, the demo’s pointer adds two meals, looks at what is left and adds another.

Try them in the Playground

When to use it

On the day screen of a nutrition or training app, in a meal diary, in a health dashboard; and for any goal made of several parts that fill together.

On phones

It is made for the phone: the card is 318 pixels wide at most, the meals are 38-pixel buttons in two columns, and with a finger the “what is left” is read by focusing the bar.

With reduced motion

Ring, bars and numbers go straight to the new value; plus and tick swap without turning and the numbers on the bar change without rolling. The demo does not move by itself.

Pitfalls

  • Meals, grams and goals are made up for the demo and are not dietary advice: in a real app they come from the person’s diary and their own goals.
  • The three bars have three colours, but each has its name written beside it: colour alone is not enough to tell them apart.
  • The meals are buttons with aria-pressed, and an aria-live region says what was added and how many calories have been reached.
  • With the elastic the grams figure wobbles by one before it settles: if that bothers, the text can be tied to a tween without bounce.
  • Plus and tick are the same path with its d attribute changed: so the disc holding them can turn without two overlapping icons.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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