Skip to content
animorio
IT
All components

Auto-renew toggle

Toggles, HoverGSAP, CSS onlyEasyCompressed weight: Demo 4.4 KBGSAP 28 KBFreeDownload the zip

The auto-renew switch of a subscription, on white: below it a bar shows the current period with the part already gone and, after it, the one to come. Turn it off and the next period withdraws, the bar stretches to its end and the words go from “Renews on 14 Dec” to the count of the days left, in amber.

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>
<!--
  "Auto-renew toggle" 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>Auto-renew toggle</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 auto-renew switch of a subscription: the bar is the period you are in; turned on, the next period
         slides in after it, turned off the period stretches to its end and the date says when it stops -->
    <section class="ar" data-ar>
      <div class="ar__head">
        <div>
          <h1 id="ar-title">Auto-renew</h1>
          <p class="ar__plan">Studio plan, €9.00 a month</p>
        </div>
        <button class="ar__switch" type="button" role="switch" aria-checked="true" aria-labelledby="ar-title" data-switch><span class="ar__knob" data-knob></span></button>
      </div>
      <div class="ar__cycle" aria-hidden="true">
        <span class="ar__now" data-nowbar><i data-spent></i></span>
        <span class="ar__next" data-nextbar></span>
        <span class="ar__today" data-today></span>
      </div>
      <p class="ar__dates" aria-hidden="true"><span>14 Nov</span><span data-edge>14 Dec</span><span data-far>14 Jan</span></p>
      <p class="ar__state"><span data-state>Renews on 14 Dec</span></p>
      <span class="ar__say" data-say aria-live="polite"></span>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

17 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Auto-renew toggle” 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, a light card: “Auto-renew” with “Studio plan, €9.00 a month” under it and, on the right, a green switch turned on. Lower down a bar: the current period, grey, with the part already gone in green and a dark notch on today; after a small gap, a second piece in pale green stripes, the period to come. Under the bar the dates, “14 Nov”, “14 Dec” and “14 Jan”, and the green words “Renews on 14 Dec”. At the opening the next period comes in on a spring. Turn the switch off and the knob slides, stretching slightly, the next period withdraws and fades with its date, the current period’s bar stretches to the edge taking the notch and the end date along, green turns amber and the words roll into “Ends on 14 Dec, 21 days left”. Turn it back on and everything returns to its place with a bounce.

How it works

One number for the bar

A single number, 0 to 1, says how much room the next period takes: the width of the two pieces, today’s notch and the position of the dates all come from it.

On and off

The click takes that number to 1 on a spring or to 0 with a soft exit; the knob slides 20 pixels and stretches for a moment.

The colour

A class on the card changes a CSS variable: the gone part of the bar and the words go from green to amber with a transition.

The words

They roll out and come back with the new text; the days left are a value to change.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#13a36cThe colour of auto-renew when on.
OFFscript.js#d98512The colour used when the subscription is about to end.
SPENTscript.js0.3How much of the period has already gone: 0 to 1.
DAYSscript.js21How many days are left until the period ends.
SPRINGscript.js1How much the knob and the bar bounce: 0.3 = a little, 2 = a lot.
LOOPscript.jstrueLeft alone, the demo’s pointer turns auto-renew off and then back on.

Try them in the Playground

When to use it

On the subscription or billing page of an app, a service, a shop with recurring deliveries, a gym. Wherever someone turning renewal off should see at once until when they can still use what they paid for.

On phones

The same card, 292 pixels wide at most: the switch is 30 pixels tall and 50 wide, the bar takes the full width and the three dates fit on one line.

With reduced motion

The knob and the bar go straight to the new state, the words change without rolling; the colours change with their transition. The demo does not move by itself.

Pitfalls

  • Plan, price and dates are made up: in a real app they come from the payments system, and the state only changes when the server confirms.
  • The switch has role=switch and takes its name from the title (aria-labelledby); a hidden aria-live line says the new state and the date.
  • The off state is not told by colour alone: the words say “Ends” with the days left.
  • The bar animates percentage widths written by the script: with three elements nothing more is needed; with many more pieces scaleX pays off.
  • Turning renewal off is not cancelling at once: the demo shows it by leaving the current period whole up to its end.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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