Skip to content
animorio
IT
All components

Stock meter

Tags, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 8.6 KBGSAP 28 KBFreeDownload the zip

The product row of a made-up home shop, Harrow & Loom: the Waffle Merino Throw with its price, three colours as small squares with a waffle weave and four sizes. Below, the stock meter: a thin bar of ten segments that shortens or grows segment by segment when the variant changes, each with a small bounce, the number rolling in “Only 4 left in Sage”, the tone moving from the black of In stock to the amber of the last few to the grey of sold out, and the delivery line saying Ships in 1–2 days or Back Dec 12. Sold out, Notify me opens into an email field inside the line and becomes We’ll email you with a tick drawing itself. Minimal style.

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>
<!--
  "Stock meter" 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>Stock meter</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 product row of a made-up home shop, Harrow & Loom: name, price, three colours, four sizes and, below,
         the stock meter: ten thin segments, the stock line and the delivery line. Out of stock, Notify me opens an email field -->
    <section class="card" data-card aria-labelledby="p-name">
      <header class="head">
        <p class="maker">Harrow &amp; Loom</p>
        <div class="title-row">
          <h2 class="name" id="p-name" data-name>Waffle Merino Throw</h2>
          <p class="price" aria-live="polite"><span class="sr" data-price-sr>$148</span><span class="roller" data-price aria-hidden="true"></span></p>
        </div>
      </header>

      <div class="group">
        <div class="label"><span>Colour</span><span class="label__val" data-colour-name>Oat</span></div>
        <div class="swatches" role="radiogroup" aria-label="Colour" data-swatches></div>
      </div>

      <div class="group">
        <div class="label"><span>Size</span><span class="label__val" data-dims>130 × 170 cm</span></div>
        <div class="sizes" role="radiogroup" aria-label="Size" data-sizes>
          <span class="sizes__mark" data-mark aria-hidden="true"></span>
        </div>
      </div>

      <div class="stock" data-stock>
        <div class="meter" data-meter aria-hidden="true"></div>
        <div class="line" data-line aria-live="polite"></div>
        <div class="sub" data-sub></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.

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 “Stock meter” 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 white background, a white card with a soft shadow: at the top, small, the name of a made-up home shop, Harrow & Loom, then the product name, Waffle Merino Throw, and the price on the right. Below, Colour with the chosen colour’s name and three rounded squares, Oat, Sage and Clay, with a fine waffle weave and a sheen; the chosen one takes a thin ring that arrives on a spring. Then Size with the dimensions in centimetres and four pills, Throw, Twin, Queen and King: a black mark slides onto the chosen one with a bounce, and the sizes sold out in the chosen colour dim and get a slanted line that draws itself. The price changes with the size and the digits roll. Under a thin rule sits the stock meter: ten thin segments, one per piece, filling from the left; changing the variant the bar shortens or grows segment by segment, and each segment that arrives makes a small elastic hop in height, while the last one left settles by a pixel. The tone of bar and word changes with a soft transition: black for In stock, amber for Only 4 left in Sage with the number rolling, grey for Out of stock in Clay. Below, the delivery line with its drawn icon: Ships in 1–2 days with the van, Back Dec 12 with the calendar. Old lines leave upwards before the new ones come in. When a variant is sold out, Notify me with a bell sits beside it, widening on the width axis on hover: tapped, the delivery line grows on a spring into an email field with a small black button; once the email is sent, Notify me goes away and the line becomes We’ll email you · back Dec 12 with a tick drawing itself. With the keyboard the arrows run through colours and sizes like two rows of radios.

How it works

Ten segments, one per piece

The bar is a grid of ten segments, each with a fill inside that GSAP takes to scaleX 1 or 0. When stock goes up they fill left to right 45 milliseconds apart and each segment hops in height with elastic.out; when it goes down they empty from the last one, and the segment left at the end settles by a pixel.

One tone that changes

Bar and word share the --tono variable on the card. GSAP takes it from the black of In stock to the amber of the last few or the grey of sold out in half a second, so segments and words change colour together, with no dot beside them.

Rolling numbers

Each digit of the price and the stock is a 0 to 9 column inside a one-line window: to change digit the column moves with yPercent and back.out. When the Only N left line comes in fresh, the digit starts from the previous number and rolls to the new one.

Lines taking turns

The stock line and the delivery line are one-cell grids: the new line sits over the old one, the old one leaves upwards in 0.2 seconds and the new one comes in from below just after. The email field enters the same way, while the line’s height goes from one line of text to 38 pixels on a spring.

Values to change

NameFileDefaultWhat it changes
PRODUCTscript.jsWaffle Merino ThrowThe product name above the price.
SEGMENTSscript.js10How many segments the bar has: one per piece, full beyond this number.
LOW_ATscript.js5From how many pieces down the line turns amber and says Only N left.
SEG_TIMEscript.js0.32How long a segment takes to fill or empty.
STAGGERscript.js0.045The delay between one segment and the next.
SPRINGscript.js1.6How far the size mark overshoots and comes back.
TONE_TIMEscript.js0.5How long the tone change between black, amber and grey takes.
SHIP_TEXTscript.jsShips in 1–2 daysThe delivery line when the product is in stock.

Try them in the Playground

When to use it

On the product page of an online shop, under the price and the variants: homeware, clothing, shoes, cosmetics, anything with colours and sizes holding different stock, or for event tickets with seat bands.

On phones

The card takes the width with a margin, the four sizes sit in a grid that tightens and heights and gaps also follow the window height with clamp, so with the email field open everything fits the preview box. Touch replaces hover.

With reduced motion

No hops or springs: segments fill at once with a fade, new lines fade in without moving, digits change in place, the tick is already drawn and the self-running preview does not start.

Pitfalls

  • A segment fill with hidden overflow clips back.out’s overshoot: the bounce goes to the whole segment, in height, not to its fill.
  • A line coming in while the old one leaves reads overlapped: the old one leaves in 0.2 seconds and the new one starts 0.12 seconds later, from below.
  • The chosen size mark is measured in pixels: it is put back in place on resize and when the font arrives, which changes the pills’ width.
  • The We’ll email you tick draws with strokeDashoffset on a pathLength 1 path: with autoRound on it would pop in at once, so autoRound is off at the top of the script.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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