Skip to content
animorio
IT
All components

Tax calculator

Sliders, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.7 KBGSAP 28 KBFreeDownload the zip

An income tax calculator on a white card: take-home pay in large green digits, the income slider to drag and three bands, 0, 20 and 40 percent, each with its own bar. Raising the income fills the bars one after the other, green first, then yellow, then red, and take-home, each band’s tax, the total and the overall rate change at every step.

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>
<!--
  "Tax calculator" 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>Tax calculator</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">
    <!-- an income tax calculator: the income to drag, the three bands filling one after the other, and
         take-home pay, tax and overall rate rolling -->
    <section class="tx" data-tx aria-label="Income tax calculator">
      <header class="tx__head"><strong>Take-home pay</strong><span>Yearly · sample rates</span></header>
      <div class="tx__sum"><strong data-outnet>$49,600</strong><span>from <b data-outgross>$62,000</b></span></div>
      <div class="tx__slide" data-track>
        <i class="tx__rail" aria-hidden="true"><i class="tx__done" data-done></i></i>
        <button type="button" class="tx__knob" data-knob role="slider" aria-label="Yearly income" aria-valuemin="20000" aria-valuemax="160000" aria-valuenow="62000"><i></i></button>
      </div>
      <ul class="tx__bands">
        <li data-band="0"><span class="tx__rate">0%</span><span class="tx__bar"><i data-fill></i></span><span class="tx__lab">first $12,000</span><b data-outtax>$0</b></li>
        <li data-band="1"><span class="tx__rate">20%</span><span class="tx__bar"><i data-fill></i></span><span class="tx__lab">up to $50,000</span><b data-outtax>$7,600</b></li>
        <li data-band="2"><span class="tx__rate">40%</span><span class="tx__bar"><i data-fill></i></span><span class="tx__lab">above $50,000</span><b data-outtax>$4,800</b></li>
      </ul>
      <footer class="tx__foot"><span>Tax <b data-outall>$12,400</b></span><span class="tx__eff"><span data-outeff>20.0% of your income</span></span></footer>
    </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.

28 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 “Tax calculator” 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 white, a rounded card: “Take-home pay” and on the right “Yearly · sample rates”; below, in green and in large digits, the take-home, “$49,600”, and beside it “from $62,000”. Then the income slider, a thin rail with the part done in black and a round white knob. Below, three rows: “0% first $12,000”, “20% up to $50,000”, “40% above $50,000”, each with a bar (green, yellow, red) and on the right that band’s tax. At the bottom “Tax $12,400” and “20.0% of your income”. On entering the income climbs from the minimum and the bars fill in turn. Dragging the knob to the right raises the income a thousand at a time: the green bar is already full, the yellow fills up to 50,000 and then the red begins; the rate of the band you are in turns black with a small jump, and take-home, taxes and the overall rate change at every step. Going back empties the red one first. On release the knob bounces; you can also tap a point on the rail or use the arrow keys.

How it works

Each band taxes its own slice

For every band you take the part of income that falls between its start and its end: that slice, times the rate, is its tax, and the slice divided by the band’s width is how full its bar is. That is why the bars fill in a row, on their own.

A single number

The state is the income. Dragging, tapping the rail, using the keyboard or the pilot change that number; everything else (take-home, three taxes, total, overall rate, knob position) is recomputed and rewritten.

The slider

The knob captures the pointer: the finger’s position on the rail becomes an income rounded to the thousand. The touch area is 44 pixels even though the knob shows 22.

The band you are in

When the income crosses a threshold a class changes on the row: the rate turns black and gives a small jump, once, not at every step.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0e9f6eThe colour of the take-home and of the tax-free band.
INCOMEscript.js62000The yearly income it starts from.
TOPscript.js160000The slider’s highest income.
SPRINGscript.js1How much the knob bounces when you let go.
LOOPscript.jstrueLeft alone, the demo’s pointer drags the income and then starts again.

Try them in the Playground

When to use it

On the site of an accountant, a payroll app or a service for the self-employed, where you need to show that the highest rate applies only to the part of income above the threshold; the same banded calculator carries usage-based pricing, volume fees, a quantity discount or a plan’s price growing in tiers.

On phones

The card is at most 344 pixels wide and about 330 tall, and narrows with the screen; below 350 pixels the take-home gets smaller. The knob has a 44-pixel touch area and the slider does not scroll the page while you drag.

With reduced motion

The slider works the same and the numbers change at every step; on entering the income is already in place, tapping the rail puts the knob there at once, with no glide, and there are no bounces or jumps. The demo’s pointer does not start.

Pitfalls

  • The rates and thresholds are samples, not a real tax system: the card says so (“sample rates”). For a real country its own bands, allowances and contributions have to go in, which are not here.
  • The mistake the piece wants to remove: thinking that past a threshold all income is taxed at the highest rate. That is why every band shows its own tax and the previous band’s bar stays full.
  • The slider is a real one (role slider) with an aria-valuetext giving income, take-home and tax; arrows move a thousand, Page Up and Down ten thousand, Home and End go to the ends. The aria-live region speaks only on release, not at every step.
  • The three bands’ colours do not carry the information on their own: every row has its rate and threshold written out.

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