Skip to content
animorio
IT
Back to the library

Hanging tags

Physics, HoverGSAP, CSS onlyMediumCompressed weight: Demo 8.2 KBGSAP 28 KBFreeDownload the zip

The filters of a furniture shop hanging from thin threads under a rail: the passing pointer pushes them and they swing like real pendulums, barely touching each other and calming down slowly. One can be pulled down by its thread, which stretches like a rubber band, and let go it springs back up; clicked, it becomes the choice, fills with colour and its thread shortens with a little hop. In the style of product micro-interactions, one gesture only: Hover.

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>
<!--
  "Hanging tags" 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>Hanging tags that swing as you pass</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 shop filters hang from a thin rail on threads: the pointer pushes them and they swing like pendulums,
         a tag can be pulled down by its thread, and a click picks it -->
    <header class="top">
      <p class="brand">Halden Home</p>
      <p class="hint">Shop by room</p>
    </header>

    <div class="rig" data-rig>
      <svg class="threads" data-threads aria-hidden="true">
        <line class="rail" data-rail x1="0" y1="0" x2="0" y2="0"></line>
        <g data-knots></g>
        <g data-paths></g>
      </svg>

      <div class="tags" role="radiogroup" aria-label="Filter the shop by room" data-tags>
        <button class="tag is-on" type="button" role="radio" aria-checked="true" data-tag data-n="128" data-room="everything"><span class="tag__clip" aria-hidden="true"></span><span class="tag__face"><span class="tag__label">All</span></span></button>
        <button class="tag" type="button" role="radio" aria-checked="false" data-tag data-n="24" data-room="lamps"><span class="tag__clip" aria-hidden="true"></span><span class="tag__face"><span class="tag__label">Lamps</span></span></button>
        <button class="tag" type="button" role="radio" aria-checked="false" data-tag data-n="31" data-room="chairs"><span class="tag__clip" aria-hidden="true"></span><span class="tag__face"><span class="tag__label">Chairs</span></span></button>
        <button class="tag" type="button" role="radio" aria-checked="false" data-tag data-n="18" data-room="tables"><span class="tag__clip" aria-hidden="true"></span><span class="tag__face"><span class="tag__label">Tables</span></span></button>
        <button class="tag" type="button" role="radio" aria-checked="false" data-tag data-n="22" data-room="rugs"><span class="tag__clip" aria-hidden="true"></span><span class="tag__face"><span class="tag__label">Rugs</span></span></button>
      </div>
    </div>

    <footer class="foot">
      <p class="count"><span class="count__n" data-count>128</span> <span class="count__rest">pieces in <span class="count__name" data-name>everything</span></span></p>
      <p class="note">Brush the tags, pull one down, or pick one.</p>
    </footer>

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

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.

25 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 “Hanging tags” 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 warm white, top left the name of an invented furniture shop, Halden Home, and on the right Shop by room. Below runs a thin rail, and five threads hang from small hooks, each its own length; at the end of each thread, hung by a tiny metal clip, a pill tag: All, Lamps, Chairs, Tables, Rugs. All is already chosen, filled with blue. Passing over them with the pointer the tags move along with it and then swing like pendulums, each at its own pace, turning a little around the clip; the threads bend slightly behind the movement and the soft shadows slide the opposite way. When two neighbours meet they touch gently and hand the push over, then everything calms down. A tag can be grabbed and pulled down: the thread turns dark and straight and stretches less and less, like a rubber band; let go, it springs back up and starts swaying again. Clicked, it becomes the choice: it fills with blue, its letters widen, its thread shortens by a few pixels with a little hop, the previous one empties and drops back. Below, the number of pieces rolls to the one of the chosen room, 24 lamps, 31 chairs, and the name changes rising. A drawn pointer does it all by itself: it brushes the row slowly to the right and faster to the left, pulls Chairs down, picks Lamps and goes back to All; then it starts again.

How it works

A row of pendulums

Each tag is a pendulum: an angle, an angular speed and the length of its thread. On every frame, in four small steps in GSAP’s ticker, gravity pulls it back down with minus G over the length times the sine of the angle, and DAMPING slows it. The tag turns by 88% of the thread’s angle around its clip, so it looks hung and not glued.

The pointer that pushes

The pointer’s speed is measured between one event and the next and fades by itself when it stops. If the pointer is over a tag’s face, its speed along the arc becomes the speed the tag wants to have, and the tag reaches it quickly: so it moves with the pointer and, as soon as the pointer leaves, it swings.

Neighbours that touch

After each step neighbouring faces are compared: if they overlap and are moving towards each other, they trade speed like two balls with a restitution of 0.35, and the overlap is split in half between them. The touch is soft and the push travels along the row.

The thread that stretches

Grabbed by its face, the tag follows the finger: the angle comes from the arctangent, and past its length the thread stretches by STRETCH times (1 minus 1 over (x over STRETCH plus 1)), less and less. Let go, the length goes back with its own spring in which BOUNCE leaves the bounce, and the angle starts again with the speed of the last ninety milliseconds.

The drawn thread

Each thread is a quadratic curve from the hook to the clip: its control point moves sideways against the speed, so the thread lags behind the movement, and when the thread is shorter than its length it curves, like a slack string. Pulled past its length it turns straight and dark.

Values to change

NameFileDefaultWhat it changes
SWINGscript.js1How fast the tags swing: higher means quicker pendulums.
DAMPINGscript.js1.1How quickly they calm down after a push.
PUSHscript.js1How hard the passing pointer pushes them.
BOUNCEscript.js0.3How much they bounce when you let go after pulling them down.
STRETCHscript.js46How many pixels at most the thread stretches when pulled.
SHORTENscript.js10How many pixels the chosen tag’s thread shortens.
ACCENTscript.js#2f5bffThe colour of the chosen tag and of the number.
HOLDscript.js1.4The seconds of pause before the autopilot starts again.

Try them in the Playground

When to use it

For the filters or the categories of a shop, a blog or a portfolio, when the choice should have a little play without losing clarity: it reads as a normal row of pills, and whoever passes over it feels it move.

On phones

The same animation with adapted sizes: the row, the length of the threads and the letters are sized on the width and the height of the window; with a finger the tags are pushed by sliding over them, pulled down and picked.

With reduced motion

No swinging and no stretching threads: the tags stay still, the choice moves from one to the next with a colour fade and the number changes without rolling.

Pitfalls

  • The pointer’s push given as a kick on every event sent the tags flying with a fast mouse: now the pointer sets a speed to reach, not a sum.
  • Without fading the pointer’s speed between events, a still pointer over a tag kept pushing it.
  • The pill widths must be measured after document.fonts.ready: with the fallback font the row was narrower and the tags overlapped at rest.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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