Skip to content
animorio
IT
All components

Feature rollout switch

Toggles, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.8 KBGSAP 28 KBFreeDownload the zip

A feature flag switch with a gradual rollout: turn it on, drag the share of users and the strip of bars (each a slice of users, in a shuffled order) lights up on a spring. The 1, 10, 50 and 100% stages get there by themselves; switching off is the kill switch.

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>
<!--
  "Feature rollout switch" 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>Feature rollout</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">
    <!-- a feature flag with a gradual rollout: switch it on, drag the share of users, and the strip of bars
         (one bar per slice of users, in a shuffled order) lights up; switching off is the kill switch -->
    <section class="fr" data-fr aria-label="Feature flag">
      <header class="fr__head">
        <span class="fr__icon" aria-hidden="true"><svg viewBox="0 0 20 20"><path d="M5.200 17V3.600"></path><path class="fr__flag" data-flag d="M5.200 4.200c3-1.600 5 1.400 8.600 0v6.600c-3.600 1.400-5.600-1.600-8.600 0Z"></path></svg></span>
        <span class="fr__name"><code>new-checkout</code><span class="fr__state"><span data-state>Off</span></span></span>
        <button class="fr__switch" type="button" role="switch" aria-checked="false" aria-label="Enable new-checkout" data-switch><span class="fr__knob" data-knob></span></button>
      </header>

      <div class="fr__body" data-body>
        <p class="fr__read">
          <span class="fr__pct"><b data-pct>0</b><i>%</i></span>
          <span class="fr__users"><b data-users>0</b> of <span data-total></span> users</span>
        </p>
        <div class="fr__bars" data-bars aria-hidden="true"></div>
        <div class="fr__slide">
          <span class="fr__track"><span class="fr__fill" data-fill></span></span>
          <span class="fr__thumb" data-thumb aria-hidden="true"></span>
          <input class="fr__range" type="range" min="0" max="100" step="1" value="0" data-range aria-label="Share of users">
        </div>
        <div class="fr__stages" data-stages role="group" aria-label="Stages"></div>
      </div>
    </section>

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

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 “Feature rollout switch” 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 dark card: at the top the tile with the little flag, the flag’s name “new-checkout” with its status below, and the switch; under it, off and dimmed, the rollout: the large percentage, how many users that is, a strip of low bars, the slider and the four stages. Turning it on, the knob stretches and settles on the other side, the little flag waves once and turns purple, the status rolls to “Rolling out”, the panel lights up and the bars of the slice already in rise, each to its own height, with a small bounce. Dragging the slider, the percentage and the user count change and bars come in or drop out one by one, scattered along the strip because the order is shuffled. The stages take the percentage to their value on a smooth run; at 100% the status says “Live for everyone”. Switching off, every bar drops together: that is the kill switch.

How it works

Who gets in first

The bars have an order shuffled once from a fixed seed: a bar is in if its place in that order is below the percentage. So the same user stays in as the rollout grows, as with a real flag.

A single number

The percentage moves fill, thumb, user count and bars. Underneath sits a real range input; the stages animate the same number with power3.inOut over GLIDE seconds.

The spring is in the CSS

Each bar changes height with a transition whose cubic-bezier overshoots and returns, with a random delay of a few hundredths; the --on variable takes switch, flag, status and shadow to purple.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#8b7bffThe colour of the feature when on.
USERSscript.js62000How many users the product has.
STARTscript.js10The percentage the rollout starts from, 0 to 100.
BARSscript.js56How many bars the users’ strip has.
GLIDEscript.js0.7How many seconds the percentage takes to reach a stage.
HOLDscript.js1.5On its own: how many seconds it stops at each stage.
LOOPscript.jstrueLeft alone, a pointer switches on, widens the rollout and then kills it.

Try them in the Playground

When to use it

In the feature flag panel of a developer tool, in the settings of an experiment or an A/B test, and wherever something new opens to a share of users before everyone.

On phones

The same component: the bars narrow with the width, the percentage and the strip shrink with the window’s height, the thumb is 22 pixels wide and is dragged by finger.

With reduced motion

No stretching knob, waving flag or runs to the stages: on, off and percentages change at once; only the bars’ short transition remains.

Pitfalls

  • Nothing is released here: in a real product each change is confirmed, logged and sent to the flag service, and 100% asks for one more confirmation.
  • The switch is a role switch and the percentage a real range input; when off, slider and stages do not respond (pointer-events) but stay readable.
  • The strip is decorative (aria-hidden): the real figure is given by the percentage and the user count.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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