Skip to content
animorio
IT
All components

Like counter button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.6 KBGSAP 28 KBFreeDownload the zip

A post’s like button, with one gesture: pressed, the heart squeezes, fills with a soft red on a spring with a little bounce, six thin strokes open around it and the counter rolls by one. Hold it and a row of drawn reactions rises (heart, thumb, star, flame): the one your finger slides onto takes the heart’s place.

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>
<!--
  "Like counter button" 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 like button with a counter</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">
    <!-- one gesture: press. A post with its row of actions. A tap on the heart likes it: the heart squeezes, fills with
         a soft red on a spring, six thin strokes open around it and the count rolls by one. Holding it opens a small row
         of drawn reactions; the one you slide onto replaces the heart -->
    <article class="post" data-card aria-label="Post by Oren Vale">
      <header class="post__top">
        <span class="avatar" aria-hidden="true"><span class="avatar__letters">OV</span></span>
        <div class="who">
          <span class="who__name">Oren Vale</span>
          <span class="who__meta">Tessaly · 2h</span>
        </div>
      </header>
      <p class="post__text">Shipped the new offline mode today. Every edit now saves on the device and syncs the moment you are back.</p>

      <div class="actions">
        <div class="likewrap">
          <!-- the reactions, drawn: they rise one after another while the heart is held -->
          <div class="tray" data-tray role="menu" aria-label="Reactions" aria-hidden="true">
            <button class="react" type="button" role="menuitem" data-react="love" aria-label="Love" tabindex="-1">
              <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 20.2s-7.4-4.4-7.4-10.1A4.2 4.2 0 0 1 12 7.5a4.2 4.2 0 0 1 7.4 2.6c0 5.7-7.4 10.1-7.4 10.1Z"/></svg>
              <span class="react__tip">Love</span>
            </button>
            <button class="react" type="button" role="menuitem" data-react="like" aria-label="Like" tabindex="-1">
              <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7.6 10.6v9H4.6v-9h3Zm0 0 3.5-6.3c1.6 0 2.5 1.1 2.2 2.7l-.6 3.1h5c1.3 0 2.1 1.1 1.8 2.3l-1.6 6c-.3 1.1-1.2 1.9-2.3 1.9H7.6"/></svg>
              <span class="react__tip">Like</span>
            </button>
            <button class="react" type="button" role="menuitem" data-react="star" aria-label="Star" tabindex="-1">
              <svg viewBox="0 0 24 24" aria-hidden="true"><path d="m12 4.2 2.4 4.9 5.4.8-3.9 3.8.9 5.4-4.8-2.5-4.8 2.5.9-5.4-3.9-3.8 5.4-.8Z"/></svg>
              <span class="react__tip">Star</span>
            </button>
            <button class="react" type="button" role="menuitem" data-react="fire" aria-label="Fire" tabindex="-1">
              <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 20.6c-3.3 0-5.7-2.3-5.7-5.5 0-3.4 2.7-5 3.5-8.5 1 .9 1.6 2 1.7 3.3 1.3-1.1 2.3-3.2 2.1-5.5 3 2.1 4.1 5.8 4.1 8.3 0 4.1-2.4 7.9-5.7 7.9Z"/></svg>
              <span class="react__tip">Fire</span>
            </button>
          </div>

          <button class="like" type="button" data-like aria-pressed="false" aria-label="Like this post, 1,284 likes" aria-haspopup="menu">
            <span class="like__fill" data-fill></span>
            <span class="like__inner">
              <span class="like__icon" data-iconbox>
                <svg class="burst" data-burst viewBox="-20 -20 40 40" aria-hidden="true"></svg>
                <svg class="glyph" data-glyph viewBox="0 0 24 24" aria-hidden="true"><path data-glyph-path d="M12 20.2s-7.4-4.4-7.4-10.1A4.2 4.2 0 0 1 12 7.5a4.2 4.2 0 0 1 7.4 2.6c0 5.7-7.4 10.1-7.4 10.1Z"/></svg>
              </span>
              <span class="like__count" data-count>1,284</span>
            </span>
          </button>
        </div>

        <button class="pill" type="button" aria-label="86 comments">
          <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 6.8C5 5.8 5.8 5 6.8 5h10.4c1 0 1.8.8 1.8 1.8v7.4c0 1-.8 1.8-1.8 1.8H11l-4 3.2V16h-.2c-1 0-1.8-.8-1.8-1.8Z"/></svg>
          <span>86</span>
        </button>
        <button class="pill pill--icon" type="button" aria-label="Share">
          <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4.5v10M8 8.3l4-3.8 4 3.8M6 12.5v5.3c0 .9.7 1.7 1.7 1.7h8.6c1 0 1.7-.8 1.7-1.7v-5.3"/></svg>
        </button>
        <span class="hint" data-hint>Hold for more</span>
      </div>
    </article>

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

28 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 “Like counter button” 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 very light grey background sits the white card of a post from a made-up app, Tessaly: an avatar with initials, Oren Vale, two hours ago, a line about the new offline mode, and below the row of actions. The first is a white pill with a thin border, a heart drawn in outline and 1,284 in tabular figures; next to it the comments, 86, and the share button, quieter, and on the right in grey Hold for more. Pressed, the heart squeezes and the pill sinks a touch; released, the heart fills with a soft red while it grows on a spring with a bounce and a small turn, six thin strokes open around it and fade, the pill takes a soft pink fill and the number turns red and rolls to 1,285, starting from the last figure. Pressed again, the heart empties and the number goes down. Held for a third of a second, a white row rises above the pill with four reactions drawn in outline, one after another: a red heart, a blue thumb, an amber star, an orange flame. As the finger slides, the one beneath grows, lifts, fills with its colour and shows its name; let go there, the row closes and that reaction takes the heart’s place in the pill, with its own colour and tint. A drawn pointer shows the whole loop on its own.

How it works

A tap or a hold

On pointerdown a gsap.delayedCall as long as HOLD starts: if the finger lifts before, it is a tap and the heart turns on or off; if the time runs out, the row of reactions opens. The button captures the pointer (setPointerCapture), so the finger can slide out of it up to the reactions.

The heart that fills

There is a single drawing, an outlined path: to light it GSAP takes the fill from transparent to the colour and, together, the icon box from 0.55 to 1 with back.out(3.2) and an eight-degree turn that straightens. For the other reactions only the path’s d attribute changes.

Six strokes, not dots

Around the icon there are six lines in a larger SVG: each starts with zero length 9 units from the centre, stretches to 16.5 with power3.out, then lets go and fades. One object holds the two radii and the opacity, rewritten every frame.

Rolling figures

Each figure of the number is a column from 0 to 9 inside a one-figure window; when the number changes only the columns that differ move, starting from the last one, like a ticking counter.

The row that rises

The row appears with back.out(2) from the corner above the pill and the four reactions rise one after another, five hundredths apart. The one under the finger grows by a third, lifts five pixels and fills; the others shrink a little.

Values to change

NameFileDefaultWhat it changes
LIKESscript.js1284How many likes the post has before the click.
HOLDscript.js0.38After how many seconds of pressing the row of reactions opens.
SQUEEZEscript.js0.8How much the heart squeezes when pressed (1 = not at all).
BURSTscript.js11 shows the six strokes opening around the heart, 0 does not.
SPRINGscript.js0.6How long the spring of the filling heart lasts, in seconds.

Try them in the Playground

When to use it

For posts, photos, comments or articles in a social network, a community, a blog or an app: a quick tap for a like and a long press for those who want to say a little more.

On phones

The same card at the same size, narrowed to the box: a tap lights the heart and a long press opens the row above the finger, which slides to the reaction and lets go there. The Hold for more hint hides on the narrowest screens.

With reduced motion

No squeezes, bounces or strokes: the heart and the pill change colour with a fade, the number changes at once and the row of reactions appears and disappears without moving.

Pitfalls

  • The button must capture the pointer (setPointerCapture) and have touch-action: none, otherwise on a phone the finger sliding towards the reactions scrolls the page and the press is lost.
  • The click that follows pointerup must not count a second time: the heart lights on pointerup, and the keyboard click (detail equal to 0) is the only one that acts on its own.
  • The reactions are SVG drawings, never emoji: a character like the heart turns into a colour emoji on an iPhone and changes from phone to phone.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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