
The star rating
Ratings, SVG, Hover
The spending card of a budgeting app, clean as a real product piece, on white: a donut in five tones of one colour draws itself slice after slice and the total rolls digit by digit in the middle. Point at a slice, or at its row, and it lifts out and thickens on a spring, the others dim and the centre tells how much and what share; Week, Month and Year bend the slices to the new shares.
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>
<!--
"Spending donut chart" 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 spending donut chart that opens on hover</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" data-stage>
<!-- the spending card of a budgeting app: a donut drawn in five tones of one colour, the total rolling in the middle,
a Week / Month / Year switch that bends the slices to the new shares, and a slice that opens when you point at it -->
<section class="spend" data-card aria-label="Fennel spending">
<header class="spend__head">
<div class="spend__title">
<svg class="spend__mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3.5c3.8 2.6 5.7 5.7 5.7 9.1a5.7 5.7 0 0 1-11.4 0c0-3.4 1.9-6.5 5.7-9.1Z"></path><path class="spend__vein" d="M12 9v10.2"></path></svg>
<div>
<p class="spend__name">Spending</p>
<p class="spend__range" data-range>Oct 1 – Oct 26</p>
</div>
</div>
<div class="tabs" role="tablist" aria-label="Period" data-tabs>
<span class="tabs__pill" data-pill aria-hidden="true"></span>
<button class="tabs__tab" role="tab" type="button" data-period="week" aria-selected="false">Week</button>
<button class="tabs__tab is-on" role="tab" type="button" data-period="month" aria-selected="true">Month</button>
<button class="tabs__tab" role="tab" type="button" data-period="year" aria-selected="false">Year</button>
</div>
</header>
<div class="spend__body">
<div class="donut" data-donut>
<svg class="donut__svg" viewBox="0 0 200 200" aria-hidden="true">
<circle class="donut__track" cx="100" cy="100" r="74"></circle>
<g data-slices></g>
</svg>
<div class="donut__center" aria-live="polite">
<p class="donut__label" data-center-lab>Total spent</p>
<p class="donut__value" data-center-val></p>
<p class="donut__note" data-center-note></p>
</div>
</div>
<ul class="legend" data-legend></ul>
</div>
<footer class="spend__foot">
<svg class="spend__trend" viewBox="0 0 16 16" aria-hidden="true" data-trend><path d="M3 5.5 8 10.5l5-5"></path></svg>
<p class="spend__insight" data-insight>12% less than September</p>
</footer>
</section>
<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>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.
23 values to change
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 “Spending donut chart” from Animorio and fit it into my siteEach slice is an SVG arc path, redrawn on every frame from its two angles, how much of it is drawn, its thickness and its lift: GSAP does not animate the drawing but a small object holding those numbers, and onUpdate rewrites the d attribute. The angles come from the period’s shares, leaving 2.4 degrees of white between one slice and the next.
Changing period erases nothing: each slice goes with power3.inOut from its angles to the new ones, three hundredths apart, so the donut bends like a single object. Meanwhile the donut dips to 97.5% and comes back, a breath.
On hover the slice goes to a bigger thickness and moves outwards along its bisector, with a back.out that overshoots by a hair; the others drop to a quarter of their opacity. Slice and legend row call the same function.
Each digit is a window one line tall holding a column from 0 to 9: GSAP moves it in yPercent to the right digit, starting from the right with a small delay per place. If the number gets longer, the old digits stay aligned to the right and the new ones are born on the left.
A sequence of steps built on the tweens’ promises takes the drawn pointer to the real spot of each slice, computed from its angles and the donut’s size, opens the slice and presses the period tabs. At the first real gesture it stops, and it starts again after eight quiet seconds.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #4f46e5 | The donut’s colour: the five slices are its tones, from darkest to lightest. |
DRAW_TIME | script.js | 0.6 | The seconds each slice takes to draw itself on arrival. |
MORPH_TIME | script.js | 0.8 | The seconds the slices take to bend to the new shares when you change period. |
LIFT | script.js | 5 | How far the pointed slice lifts out of the donut. |
THICKEN | script.js | 6 | How much the pointed slice thickens. |
PAUSE | script.js | 1.2 | The seconds the autopilot stays on each slice. |
For the dashboard of a finance or budgeting app, the spending summary of an online bank, a shop’s statistics split by category, any total to explain in parts.
The card takes the width of the box, the donut drops to 40vw or 36vh and the legend stays beside it; under 380 pixels the period tabs and the rows tighten a little. A tap on a slice or a row opens it like the mouse hover.
No lifts and no springs: the pointed slice only thickens and the others dim, the change of period is a fade of the donut, the figures change without rolling and the drawn pointer stays hidden.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 8.0 KB; the libraries: GSAP 28 KB.
Tested on 26 October 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.