Source Code

<div class="container py-5 d-flex justify-content-center">
  <div class="card bsflag-card">
    <div class="card-body p-3">
      <h6 class="fw-bold mb-2">Feature flags</h6>
      <ul class="list-unstyled mb-0" id="bsflagList"></ul>
    </div>
  </div>
</div>

Bootstrap Feature Flag Toggle Panel — Free HTML CSS JS Snippet

Bootstrap Feature Flag Toggle Panel · Dashboards · Plain HTML, CSS & JS · Live preview

What's included

Features

Each flag pairs an on/off state with a rollout percentage, kept consistent with each other automatically
The rollout slider only exists in the DOM while its flag is actually enabled
Disabling a flag resets its rollout instead of leaving a stale, misleading percentage behind
Re-enabling a flag defaults to a full 100% rollout rather than an ambiguous leftover value
Two narrowly-scoped delegated listeners (change and input) handle every row without per-row re-binding

About this UI Snippet

Bootstrap Feature Flag Toggle Panel — HTML, CSS & JavaScript

Screenshot of the Bootstrap Feature Flag Toggle Panel snippet rendered live

Each flag is a small object carrying both an on boolean and a rollout percentage, and the two are kept honest with respect to each other rather than tracked independently — switching a flag off sets rollout = 0, since a disabled flag showing a stale "25%" the next time someone glances at it would misrepresent what's actually happening in production. Switching a flag back on from a zeroed rollout jumps it to 100%, on the assumption that re-enabling a flag most often means "turn it back on for everyone," not "quietly resume some old partial rollout."

The rollout slider only renders at all while its flag is on — d-none toggles alongside the switch's own checked state — so there's no way to see (or accidentally drag) a rollout percentage for a flag that's currently off, which would be a meaningless value to display or edit in the first place.

The switch and the slider are handled by two separate, narrowly-scoped listeners on the same list — one listening for change events matching .bsflag-toggle, the other for input events matching .bsflag-slider — using event delegation on the parent <ul> rather than attaching a listener to every individual row, so newly rendered rows are automatically covered without re-binding anything after every render() call.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Hand this snippet to an AI coding assistant like Claude and ask it to add a per-flag "target audience" selector (e.g. internal users only, beta users, everyone) alongside the rollout percentage, or to add an audit trail showing who last changed each flag and when.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a Bootstrap 5.3 feature flag toggle panel, using the real Bootstrap CDN framework (bootstrap.min.css and bootstrap.bundle.min.js), not custom CSS made to resemble it.

Requirements:
- A list of at least 4 feature flags, each with a name, description, an on/off switch (Bootstrap's real form-switch), and a rollout percentage slider.
- The rollout slider for a given flag must only be visible while that flag is enabled — it should disappear entirely the instant the flag is turned off, not just disable itself.
- Turning a flag off must reset its stored rollout percentage to 0. Turning a flag back on from a zero rollout must default it to 100%, not leave a misleading stale value.
- The rollout percentage label must update live while dragging the slider, not only after release.
- Use event delegation on the list container to handle both the switches and the sliders, rather than attaching individual listeners to each row.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Step by step

How to Use

  1. 1
    Load the snippetFour flags show, two enabled with visible rollout sliders and two disabled with no slider showing.
  2. 2
    Drag the "AI summaries" rollout sliderThe percentage label updates live as you drag, without needing to release first.
  3. 3
    Turn off "New navigation"Its rollout slider disappears entirely, and its rollout resets to 0% internally.
  4. 4
    Turn "New navigation" back onIt jumps straight to 100% rollout rather than an ambiguous or stale prior value.
  5. 5
    Turn on "Dark mode"Its rollout slider appears fresh, ready to be adjusted from 100%.

Real-world uses

Common Use Cases

DEV
Internal admin tools for engineering and product teams
A realistic feature-flag management panel, the kind of tool sitting behind most gradual-rollout systems.
Internal dashboards controlling gradual feature rollouts
Pairs with bootstrap-deployment-status-panel for a fuller release-management view.
A/B testing and experiment control panels
The same toggle-plus-percentage pattern applies directly to controlling experiment traffic allocation.

Got questions?

Frequently Asked Questions

A disabled flag with a leftover "25%" showing (even if hidden from view) would misrepresent the flag's actual state the next time someone re-enables it and expects a fresh decision, not a silently resumed old value.

This demo treats re-enabling as a deliberate "turn it back on" decision defaulting to full rollout; a real system might instead ask explicitly, or genuinely remember the last rollout value if that behavior is preferred — both are reasonable, differing product decisions.

Live — it listens for the "input" event, which fires continuously while dragging, rather than "change", which only fires once the drag ends.

Yes. Keep the flags array in component state, update the relevant flag's on/rollout fields immutably on toggle or slider change, and conditionally render the rollout slider based on that flag's on value.