Skip to content
animorio
IT
All components

Resend code button

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

One button, one sign, in the simple style of product interface pieces: after the sign-in code is sent the pill waits, grey, «Resend in 0:09», with the seconds counting down on thin vertical rollers and a ring drawing itself around. When the ring closes it grows an arrowhead and becomes the resend arrow, the pill turns black and says «Resend code». On tap the arrow spins once and unwinds into a check: «Code sent».

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>
<!--
  "Resend code 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 Resend code button with the countdown that closes into an arrow</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>
    <!-- one button, one sign: the countdown ring closes, grows an arrowhead and becomes the resend icon -->
    <button class="resend" type="button" data-resend aria-disabled="true" aria-live="polite" aria-label="Resend code in 9 seconds">
      <span class="resend__body" data-body>
        <svg class="resend__icon" viewBox="0 0 24 24" aria-hidden="true">
          <g data-turn>
            <path class="resend__track" d="M12 4A8 8 0 1 1 5.07 8"/>
            <path class="resend__ring" data-ring d="M12 4A8 8 0 1 1 5.07 8"/>
            <path class="resend__head" data-head d="M2.2 8.6 5.07 8 5.8 10.85"/>
          </g>
          <path class="resend__check" data-check d="M7.4 12.3l3.1 3.1 6.1-6.7"/>
        </svg>
        <span class="resend__label" aria-hidden="true">
          <span class="resend__word resend__word--wait" data-word="wait"><span class="resend__lead" data-lead>Resend in</span> <span class="resend__time"><span class="resend__min" data-min>0</span>:<span class="resend__slot" data-slot="tens"></span><span class="resend__slot" data-slot="ones"></span></span></span>
          <span class="resend__word" data-word="ready">Resend code</span>
          <span class="resend__word" data-word="sent">Code sent</span>
        </span>
      </span>
    </button>
  </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.

20 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 “Resend code 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 white, alone in the middle, there is a light grey pill, quiet like a button that cannot be pressed yet: it says «Resend in 0:09». Each digit of the seconds sits in its own thin vertical roller with soft edges: every second the roller moves on by one digit, goes a pixel too far and settles, and the digit stretches by a hair as it moves. Beside the words a ring in the accent colour draws itself from the top, clockwise, over a barely visible track, as much as the time that has passed. When it reaches zero the track fades, an arrowhead grows from the ring’s tail and the ring becomes the resend icon, winding back a little on a spring; the pill turns black with a soft shadow, swells once and the words become «Resend code», coming in narrow and opening up on the width axis. On tap the pill gives and comes back on a spring, the arrow spins one full turn, then the ring unwinds from its tail and a check draws in its place, a pixel too far and back: «Code sent». A moment later the pill turns grey again and the countdown starts over. Tapped while counting, it gives a small no, two pixels each way. Hovering when it is ready brings the pill closer and winds the arrow back. Until someone touches it, it plays the whole round by itself.

How it works

A ring that becomes an icon

The icon is an SVG of four paths: a 300 degree arc, the same arc underneath as a thin track, the arrowhead and the check. The countdown draws the arc with strokeDashoffset, from its length to zero, as much as the time that has passed; at zero the arrowhead scales from 0 to 1 around the arc’s tail (svgOrigin) with back.out, and the arc with its head is already the resend arrow.

The digit rollers

Each digit of the seconds is a column 9, 8, 7 … 0, 9 inside a 0.62 em slot with hidden overflow and a soft mask top and bottom. Counting down the roller always moves forward by one cell; from 0 to 9 it goes to the last 9 and then jumps, unseen, to the first. Every step uses back.out, so it goes a pixel too far and comes back.

Real seconds

The countdown is a single linear tween of a number from WAIT to zero, WAIT real seconds long: onUpdate draws the ring continuously and turns the rollers only when the whole second changes. SPEED changes the springs, never the length of the wait.

The pill’s two faces

Grey with a hairline border while it waits, black with a shadow when it is ready: GSAP moves colour, text and shadow together. The words swap as in the Mute button: the old ones rise and leave, the new ones come in narrow (wdth 75) and open up, and the pill follows the width of the new words measured at their final shape.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2f6bffThe colour of the ring, the arrow and the check.
WAITscript.js9How many seconds before the code can be sent again (apps often use 30).
LABEL_WAITscript.jsResend inThe words before the seconds.
LABEL_READYscript.jsResend codeThe words once it can be tapped.
LABEL_SENTscript.jsCode sentThe words after the tap.
SPRINGscript.js1How springy the press, the digits and the pill are: 0.4 calm, 2 very bouncy.
SPEEDscript.js1The speed of the movements: 2 twice as fast, 0.5 half (the countdown keeps real seconds).
HOLDscript.js1.6How many seconds «Resend code» waits before the button taps itself.
AUTOscript.jstrueThe button plays the whole round by itself until someone touches it.

Try them in the Playground

When to use it

On the verification code screen of a sign-in, a sign-up or a payment: whoever is waiting sees how long is left without reading a notice, and understands by themselves when they can ask for a new code.

On phones

On the phone the pill and the icon take their size from the screen (clamp on the shorter side); there is no hover, everything else is the same.

With reduced motion

The digits change in place with no roll, the ring still draws because it is the time passing, the arrowhead, the check and the words fade in; no springs, no spin, no shake.

Pitfalls

  • A roller with the digits 0 to 9 in a row, counting down, would spin all the way back from 0 to 9: with the column 9 … 0, 9 it always moves forward by one cell and then jumps to the first 9, identical.
  • Mona Sans has no equal-width digits and its tabular figures give a slashed zero: each digit sits in a 0.62 em slot, so the words do not wobble every second.
  • The countdown must not follow SPEED: a 9 second wait turning into 4.5 would be a lie. The springs go through D(), the countdown does not.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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