Skip to content
animorio
IT
All components

Tailor’s needle button

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

The button that books a hem or an alteration at a tailor’s. Pressed, the needle leaves the disc and goes round the pill leaving a line of red thread stitches behind it, just inside the edge; when the seam closes the tick draws itself and the tag says when it will be ready.

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>
<!--
  "Tailor’s needle 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>Book an alteration button of a tailor with the needle that sews the edge of the pill</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 button that books an alteration at a tailor's: pressed, a needle runs along the edge of the pill and
         leaves a line of stitches behind it; when the seam closes a tick draws itself and the tag says when it is ready -->
    <button class="tl" type="button" data-tl>
      <span class="tl__body" aria-hidden="true"><span class="tl__wash" data-wash></span><span class="tl__light"></span></span>
      <span class="tl__edge" aria-hidden="true"></span>
      <svg class="tl__sew" data-sew aria-hidden="true">
        <defs><mask id="tl-mask" maskUnits="userSpaceOnUse"><rect class="tl__reveal" data-reveal pathLength="1"></rect></mask></defs>
        <rect class="tl__stitch" data-stitch mask="url(#tl-mask)"></rect>
        <g data-needle><path class="tl__needle" d="M-7 0H8"></path><ellipse class="tl__eye" cx="-5" cy="0" rx="1.800" ry="0.900"></ellipse></g>
      </svg>

      <span class="seat" data-seat aria-hidden="true">
        <svg viewBox="0 0 24 24">
          <g data-icon>
            <path class="seat__thread" d="M7.300 16.700c-2.600 1.700-3.800-1.200-1.600-2.300 2.400-1.200 4.600 2.800 2 4.300"></path>
            <path class="seat__needle" d="M6.500 17.500 18.200 5.800"></path>
            <ellipse class="seat__eye" cx="8.300" cy="15.700" rx="1.700" ry="0.850" transform="rotate(-45 8.300 15.700)"></ellipse>
          </g>
          <path class="seat__tick" data-tick pathLength="1" d="M7.500 12.400 10.600 15.300 16.500 8.800"></path>
        </svg>
      </span>

      <span class="label">
        <span class="label__main"><span data-word>Book an alteration</span></span>
        <span class="label__sub"><span data-sub></span></span>
      </span>
      <span class="tag" aria-hidden="true"><span data-left></span></span>
    </button>
    <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.

14 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 “Tailor’s needle 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 black, a light pill 60 pixels high: on the left a white disc with a needle and a curl of red thread, in the middle “Book an alteration” and below it “Trousers, hem”, on the right a tag with the price. On hover the light follows the pointer and the needle peeks out. Pressed: a red tint leaves the disc, the needle leaves the disc and reappears on the edge, then runs all the way round the pill going in and out of the cloth, and behind it the stitches appear, one after the other, five pixels from the edge. Once the seam is closed the pill gives for a moment like cloth pulled by a knot, everything turns green (the thread too), the tick draws itself and the tag says “Fri”. After a few seconds the thread is pulled out quickly and the needle goes back into the disc.

How it works

The stitches and the mask

An SVG rounded rectangle, five pixels inside the pill, with a dashed stroke (5 and 4.5): those are the stitches. A mask with the same rectangle and pathLength 1 uncovers it with stroke-dashoffset: so the dashes stay still and appear one at a time.

The needle at the head

From the same number the point on the rectangle is read with getPointAtLength and, two pixels further on, the direction: the needle sits there rotated, with a small sideways wave (a sine on the length) that takes it in and out of the cloth. All written into the transform attribute.

Measured on the button

The rectangle takes width and height from the real button, at every resize and once the font has arrived. The lap uses sine.inOut: it starts gently, keeps the pace, slows on the last stitches.

Values to change

NameFileDefaultWhat it changes
JOBscript.js"Trousers, hem"The alteration to book (made up).
PRICEscript.js18The price, in euros (made up).
READYscript.js"Friday"When it is ready (made up).
SEWscript.js1.5How many seconds the needle takes to go round the pill.
ACCENTscript.js#d9463eThe colour of the thread.
OKscript.js#2f9d6aThe colour once the alteration is booked.
HOLDscript.js2.6Alone: how many seconds the confirmation stays before going back.
LOOPscript.jstrueLeft alone, a pointer tries it by itself.

Try them in the Playground

When to use it

On the site of a tailor, a dry cleaner that does repairs or a cobbler, on a garment’s page of a shop that offers hemming, in any made-to-measure service to book.

On phones

The same pill, at most as wide as the screen minus the margins: the seam is measured again on the real width. There is no hover, the tap does the same job.

With reduced motion

The needle does not run: the stitches appear all together, the texts change without rolling and the tick appears.

Pitfalls

  • Animating the dashes’ stroke-dashoffset would make them crawl along the edge like ants: to make them appear in place you need the mask.
  • getPointAtLength on a rect works in today’s browsers; the rectangle must be measured after the button has its width, and again when the font arrives.
  • The mask uses maskUnits userSpaceOnUse: with the default units a wide stroke would leave the mask’s box and be clipped.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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