Skip to content
animorio
IT
All components

Follow button with avatars

Buttons, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 8.6 KBGSAP 28 KBFreeDownload the zip

The Follow button on an invented photographer’s profile, on white: three round avatars that are tiny landscape photos, the follower count and the black pill. Pressed, the pill squeezes and turns light on «Following» with a blue check that draws itself, the counter’s digits roll one by one to the next number, and the avatar row opens to let yours in, with a «You» tag. On a second click the «Unfollow?» question opens inside the pill with two buttons, and everything goes back.

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>
<!--
  "Follow button with avatars" 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 Follow button with the avatar row that makes room for yours</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 Follow row of a film photographer's profile: who follows, how many, and the pill -->
    <div class="fit" data-fit>
      <div class="row" data-row role="group" aria-label="Ines Marlow, film photographer">

        <div class="stack" data-stack aria-hidden="true">
          <span class="av av--me" data-me><span class="av__photo"></span><span class="tip" data-tip>You</span></span>
          <span class="av av--a" data-friend><span class="av__photo"></span></span>
          <span class="av av--b" data-friend><span class="av__photo"></span></span>
          <span class="av av--c" data-friend><span class="av__photo"></span></span>
        </div>

        <div class="count" data-countbox>
          <span class="count__num" data-num aria-hidden="true"></span>
          <span class="count__label">followers</span>
          <span class="sr" data-numtext></span>
        </div>

        <div class="slot" data-slot>
          <div class="pill" data-pill>
            <div class="pill__body" data-body>
              <span class="pill__paper" data-paper aria-hidden="true"></span>
              <span class="pill__ink" data-ink aria-hidden="true"></span>
              <span class="pill__shine" aria-hidden="true"></span>

              <button class="pill__hit" type="button" data-hit data-autoclic aria-pressed="false" aria-label="Follow Ines Marlow"></button>

              <span class="face face--follow" data-face="follow" aria-hidden="true">
                <span class="face__in">
                  <svg class="ico ico--plus" data-plus viewBox="0 0 16 16"><path d="M8 3v10M3 8h10"/></svg>
                  <span class="face__word" data-word>Follow</span>
                </span>
              </span>
              <span class="face face--following" data-face="following" aria-hidden="true">
                <span class="face__in">
                  <svg class="ico ico--check" viewBox="0 0 16 16"><path data-check d="M3.2 8.4 6.6 11.6 12.8 4.6"/></svg>
                  <span class="face__word" data-word>Following</span>
                </span>
              </span>
              <span class="face face--confirm" data-face="confirm">
                <span class="face__in">
                  <span class="face__ask" data-ask>Unfollow?</span>
                  <button class="mini mini--no" type="button" data-no aria-label="Keep following" tabindex="-1">
                    <svg class="mini__ring" viewBox="0 0 40 40" aria-hidden="true"><circle data-ring cx="20" cy="20" r="18.5"/></svg>
                    <svg class="ico ico--x" viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 4.5l7 7M11.5 4.5l-7 7"/></svg>
                  </button>
                  <button class="mini mini--yes" type="button" data-yes tabindex="-1">Yes</button>
                </span>
              </span>
            </div>
          </div>
        </div>

      </div>
    </div>
    <p class="sr" data-live aria-live="polite"></p>

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

26 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 “Follow button with avatars” 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

A single row, 60 pixels tall, on white. On the left three overlapping 40 pixel round avatars, with a white edge and a soft shadow: each is a tiny landscape photo made of gradients (a violet dawn, the sea, a forest), with the horizon, a low sun and the lens sheen. In the middle «24,819» with «followers» in grey below. On the right the black pill with a thread of light on top, the plus and «Follow». On hover (or with the Tab key) the pill swells on a spring, the label widens on the wdth axis, the plus turns a quarter and a soft light follows the pointer; pressed it sinks. On click it squeezes, bounces and turns light with a thin border: «Follow» leaves upwards, «Following» comes in from below and the blue check draws itself. Meanwhile the changed digits roll one by one, units first then tens, to «24,820», a pixel too far and settling; the avatars open by a few pixels and yours, blue, comes into the first place with a widening ring and the «You» tag for a moment. On a second click the pill stretches, the row shifts to make room without covering anything, and «Unfollow?» opens inside with a round cancel button, with a thin ring that runs down, and «Yes»; with Yes everything goes back (counter included, the digits roll backwards), with the round button, Esc or when the ring runs out it is «Following» again.

How it works

Digits on strips of twenty

Every digit is a 24 pixel window on a strip with 0-9 repeated twice. To go up from 9 to 0 it moves to position 10 and is then put back at 0 unseen; to go down it starts from 10. Only the changed digits roll, right to left with a stagger, with back.out for the pixel too far and a soft mask above and below.

The pill with three faces

The pill is a layer that grows from the right inside its slot in the row, which grows with it so nothing overlaps: the three faces (Follow, Following, the question) sit on top of each other and their widths are measured from the words with offsetWidth, which ignores the scale. The black and the light fill are two layers fading into each other, so the colour change never touches the width spring.

Squeeze and bounce

The click gesture lives on an inner element: scaleX drops to SQUEEZE in 0.13 seconds and comes back with elastic.out, while the width arrives on its own spring. One element for the width, its child for the scale, so GSAP never mixes the two transforms.

The row that makes room

The avatars are absolute and move with x: first a little past their new place, then back on a spring, staggered; yours drops in from above with back.out and a ring in a CSS variable that widens and fades. Every avatar is a horizon in linear-gradient with a sun in radial-gradient, no face.

Confirmation, keyboard and pilot

The question lives inside the pill: the main button stops taking the pointer, focus moves to the round button, Esc closes, the round button’s ring runs down with stroke-dashoffset and closes by itself at the end. aria-pressed, aria-expanded and aria-live tell the state. The pilot’s drawn pointer follows, waits, asks to unfollow and says yes; at the first real touch it stops and starts again after six quiet seconds.

Values to change

NameFileDefaultWhat it changes
FOLLOWERSscript.js24819How many followers the photographer has before the click.
ACCENTscript.js#2f5bffThe accent colour: the check, your avatar and the focus ring.
SQUEEZEscript.js0.9How much the pill squeezes on click (1 not at all).
SPRINGscript.js0.42How much the pill bounces after the squeeze (lower is springier).
ROLL_STAGGERscript.js0.09Seconds between one rolling digit and the next.
STEPscript.js26Step in pixels between one avatar and the next in the row.
CONFIRM_TIMEscript.js4Seconds the «Unfollow?» question stays open.
PRESS_SCALEscript.js0.955How far the pressed pill sinks.

Try them in the Playground

When to use it

On a creator’s profile on a social app, a photography platform, a portfolio with a community, a blog or a podcast: the button to follow. The question inside the pill avoids unfollowing by mistake without opening a dialog.

On phones

The same animation: if the screen is narrower than the row, the whole row scales down in proportion (worked out again on resize). A tap is the click; hover is not needed.

With reduced motion

Nothing moves: the pill changes width without a spring or a squeeze, faces and avatars fade in at their place, the digits change in one step with a fade, the «You» tag appears and fades; the pilot’s pointer is hidden.

Pitfalls

  • With a ten digit strip the step from 9 to 0 rolled backwards through every number: with the doubled strip it goes forward to 10 and the position is put back to 0 once the roll is over.
  • The «Unfollow?» question first grew over the counter and covered it: now the pill’s slot grows with it and the row shifts.
  • Widths measured with getBoundingClientRect changed with the row’s scale on phones: offsetWidth reads them without the transforms.

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