Skip to content
animorio
IT
All components

Active filter pills

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

The active filters bar over the results of Larchway, a made-up camping gear shop, in the premium style of Dribbble shots: the chosen filters are pills with an x drawn in SVG. When they no longer fit the row, the last ones stack and fall into a green +3 pill whose number rolls; hovering it fans the pile open. Removing a pill squashes it away while the others close up on a spring, a pill from the pile comes back to the row if there is room and the number of results rolls; Clear all sends them off in a cascade.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React tab holds the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Active filter pills" 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 active filters in pills that gather in the count</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 active filters bar of Larchway, a made-up camping gear shop: the filters chosen are pills with a drawn x.
         When they do not fit the row, the last ones stack and fly into a +3 pill whose count rolls; hovering it fans
         the pile open. Removing a pill squashes it away while the others close up on a spring, and the results roll -->
    <section class="panel" data-panel aria-label="Active filters">
      <header class="panel__head">
        <div class="panel__title">
          <span class="panel__crumb">Larchway <span class="panel__sep">/</span> Tents &amp; shelters</span>
          <p class="panel__count"><span class="roll" data-results>128</span> <span class="panel__word">results</span></p>
        </div>
        <button class="clear" type="button" data-clear>
          <span class="clear__face">Clear all</span>
        </button>
        <button class="clear clear--restore" type="button" data-restore hidden>
          <svg class="clear__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.2 6.4a5 5 0 1 1 .4 4.4"/><path d="M3 2.8v3.8h3.8"/></svg>
          <span class="clear__face">Restore filters</span>
        </button>
      </header>

      <div class="row" data-row>
        <p class="row__empty" data-empty>No filters on. Showing every tent and shelter.</p>
        <div class="more" data-more>
          <button class="more__btn" type="button" data-more-btn aria-expanded="false" aria-haspopup="true">
            <span class="more__pile" aria-hidden="true"></span>
            <span class="more__face" data-more-face>
              <span class="more__plus" aria-hidden="true">+</span><span class="roll" data-more-n>3</span>
              <span class="sr">more filters</span>
              <span class="more__sheen" data-sheen aria-hidden="true"></span>
            </span>
          </button>
        </div>
      </div>

      <div class="results" data-results-list aria-hidden="true">
        <div class="tile" data-tile>
          <span class="tile__swatch tile__swatch--pine">
            <svg viewBox="0 0 64 40"><path d="M10 33 32 9l22 24"/><path d="M32 9v24"/><path d="M26 33l6-9 6 9"/><path d="M6 33h52"/></svg>
          </span>
          <span class="tile__name">Ridge 2 Tent</span>
          <span class="tile__meta"><span>$289</span><span class="tile__dim">1.8 kg</span></span>
        </div>
        <div class="tile" data-tile>
          <span class="tile__swatch tile__swatch--sand">
            <svg viewBox="0 0 64 40"><path d="M8 33c6-14 14-21 24-21s18 7 24 21"/><path d="M20 33c3-8 7-12 12-12s9 4 12 12"/><path d="M5 33h54"/></svg>
          </span>
          <span class="tile__name">Cinder UL 2</span>
          <span class="tile__meta"><span>$349</span><span class="tile__dim">1.1 kg</span></span>
        </div>
        <div class="tile tile--third" data-tile>
          <span class="tile__swatch tile__swatch--slate">
            <svg viewBox="0 0 64 40"><path d="M7 33 20 17h26l11 16"/><path d="M20 17l6 16"/><path d="M5 33h54"/></svg>
          </span>
          <span class="tile__name">Talus Bivy</span>
          <span class="tile__meta"><span>$199</span><span class="tile__dim">0.9 kg</span></span>
        </div>
      </div>
    </section>

    <svg class="cursor" data-cursor viewBox="0 0 24 24" aria-hidden="true"><path d="M5 2.8v16.4l4.2-4 2.8 6.2 2.9-1.3-2.8-6.1h5.9Z"/></svg>
    <p class="sr" aria-live="polite" data-live></p>
  </main>

  <template data-pill-tpl>
    <div class="pill">
      <span class="pill__in">
        <span class="pill__key"></span><span class="pill__label"></span>
        <button class="pill__x" type="button">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path class="pill__x-a" pathLength="1" d="M5 5l6 6"/><path class="pill__x-b" pathLength="1" d="M11 5l-6 6"/></svg>
        </button>
      </span>
    </div>
  </template>

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

37 values to change

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 “Active filter pills” 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 page sits the warm white results panel of Larchway, a made-up camping gear shop: on top Larchway / Tents & shelters and the big number of results, on the right Clear all; below, the row of active filters, a thin rule and three products without photos (Ridge 2 Tent, Cinder UL 2, Talus Bivy), each with a soft pine, sand or slate swatch and the line drawing of the tent, the price and the weight. The seven filters arrive one after the other from the right on a spring, and the number rolls from 412 to 128. When the row is full a green pill with the count appears: the filters that do not fit show up above it and drop inside, the pill squashes, a glint crosses it and the number rolls to +3; behind it two lighter pills show the stack. The drawn pointer rests on the +3 and the pile fans open downwards: the pills come out one after the other, each turned a little more, with a longer shadow. On Waterproof the x fills with green, turns and draws itself again; pressed, the pill widens and squashes for an instant and is gone, the fan closes up to two and the count goes to +2. Then the pointer removes Sleeps 2 from the row: the others close up on a spring that passes the mark by a pixel, a pill from the pile comes back to the row, the count rolls to +1 and the results go up. Clear all sends the pills off in a cascade from the right, each squashing and falling with a turn; the results go back to 412, No filters on appears and Clear all becomes Restore filters, which brings them all back.

How it works

How many pills fit the row

The pills are all absolute in the row and GSAP puts them in place with x and y. A function adds up the widths (offsetWidth, which ignores transforms) with the gaps: if they do not all fit, it keeps only those that also leave room for the +N pill, and the rest go to the pile. Widths and row are read again on resize, and everything goes back in place without animation.

The pile and the fan

In the pile the pills sit at the centre of the +N, scaled to 0.45 and transparent (with inert, so the Tab key does not find them). With the fan open they go under the +N, one per step, aligned to the side of the nearest edge, with an offset that grows with the square of the step and a rotation from -2.4 to +2.4 degrees around the +N side, staggered by 60 milliseconds.

The spring written as an ease

The moves use an ease that is the response of a damped spring (1 − e^(−ζωt)(cos ωd t + …), normalised so it ends at 1): with BOUNCE at 0.82 a pill moving a hundred pixels passes the mark by less than a pixel and settles. The same spring, softer, rolls the digits.

The digits on the drum

Each digit of the results and of the +N is a column of 0 to 9, ten lines tall, inside a window one line tall with a soft mask on top and bottom. Changing the number means moving each column with yPercent = −digit × 10, right to left with a 35 millisecond stagger. The window needs align-items: flex-start, or flexbox stretches the column to one line.

Removing and clearing

The removed pill widens and flattens in 90 milliseconds (scaleX 1.07, scaleY 0.8), then closes into itself and is gone; a tenth of a second later the row rearranges, so the squash reads before the others arrive. Clear all starts from the rightmost pill: each squashes and drops 14 pixels with a 4 degree turn.

Values to change

NameFileDefaultWhat it changes
BOUNCEscript.js0.82The spring of the pills: lower passes the mark further and comes back (0.6), 1 lands with no overshoot.
SPEEDscript.js1The speed of every move: 2 twice as fast, 0.5 half.
GAPscript.js8The space between two pills, in pixels.
FANscript.js1How much the pile turns as it fans open (0 a straight list).
STACKscript.js0.06The delay between one pill and the next in the cascades, in seconds.
TOTALscript.js412The results with no filter on.
LOOPscript.jstrueThe drawn pointer plays the story again and again.

Try them in the Playground

When to use it

For the results page of an online shop, a catalogue or a search with many filters (homes, travel, job offers, products): it keeps the row of active filters on one line, phone included, without losing sight of how many there are and without wrapping the page. It also works in a dashboard with filtered tables.

On phones

The same animation with adapted sizes: the panel is 94% of the screen wide, two pills fit the row and the other five go into the +5, the fan tightens its steps to fit the frame and there are two products. On touch the +N opens and closes the fan, and a tap outside closes it.

With reduced motion

Nothing moves: the pills fade in and out in their place, the fan opens with a fade already spread, the digits change at once with a flash of opacity and there is no drawn pointer.

Pitfalls

  • The digit columns inside an inline-flex window were stretched to one line by the default align-items, and yPercent −10 moved by a tenth of a line: bits of zeros showed. It needs align-items: flex-start.
  • Clear all and Restore filters had display: inline-flex in the class, which beats the hidden attribute: both showed. It needs a [hidden] rule with display: none.
  • Widths read before the variable font had loaded were those of the system font and the row got the count wrong: the story starts from document.fonts.ready.
  • The pills in the pile, even transparent, could be reached with Tab: they are inert while the fan is closed.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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