Snippets Input

Bootstrap 5 Rating Scale Radio Selector

A five-step radio scale with a sliding indicator that follows the selected option, usable by keyboard and screen reader.

Bootstrap 5 No jQuery Aug 2019 2.2K views

<section class="wdw-stage">
  <div class="container" style="max-width: 640px">
    <div class="wdw-card overflow-hidden">
      <div class="wdw-aurora p-4 p-md-5">
        <span class="wdw-eyebrow mb-2 text-white-50">Quick survey</span>
        <h2 class="wdw-heading h3 mb-1 text-white">How was your onboarding?</h2>
        <p class="mb-0 text-white-50">Pick the face that fits best. It takes one tap.</p>
      </div>
      <div class="p-4 p-md-5">
      <fieldset class="rs-scale" data-rs>
        <legend class="visually-hidden">Rate your onboarding from 1 to 5</legend>
        <span class="rs-thumb" aria-hidden="true"></span>
        <input class="rs-input" type="radio" name="onboarding" id="rs1" value="1" data-word="Very poor" checked>
        <label class="rs-label" for="rs1"><svg viewBox="0 0 24 24" width="40" height="40" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="10" r=".9" fill="currentColor"/><circle cx="15" cy="10" r=".9" fill="currentColor"/><path d="M8 17c1.2-2 2.6-3 4-3s2.8 1 4 3"/></svg><span class="visually-hidden">1 - Very poor</span></label>
        <input class="rs-input" type="radio" name="onboarding" id="rs2" value="2" data-word="Poor">
        <label class="rs-label" for="rs2"><svg viewBox="0 0 24 24" width="40" height="40" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="10" r=".9" fill="currentColor"/><circle cx="15" cy="10" r=".9" fill="currentColor"/><path d="M9 16.2c.9-.6 1.9-.9 3-.9s2.1.3 3 .9"/></svg><span class="visually-hidden">2 - Poor</span></label>
        <input class="rs-input" type="radio" name="onboarding" id="rs3" value="3" data-word="Okay">
        <label class="rs-label" for="rs3"><svg viewBox="0 0 24 24" width="40" height="40" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="10" r=".9" fill="currentColor"/><circle cx="15" cy="10" r=".9" fill="currentColor"/><path d="M9 15.5h6"/></svg><span class="visually-hidden">3 - Okay</span></label>
        <input class="rs-input" type="radio" name="onboarding" id="rs4" value="4" data-word="Good">
        <label class="rs-label" for="rs4"><svg viewBox="0 0 24 24" width="40" height="40" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="10" r=".9" fill="currentColor"/><circle cx="15" cy="10" r=".9" fill="currentColor"/><path d="M8.5 14c1 1.5 2.2 2.2 3.5 2.2s2.5-.7 3.5-2.2"/></svg><span class="visually-hidden">4 - Good</span></label>
        <input class="rs-input" type="radio" name="onboarding" id="rs5" value="5" data-word="Excellent">
        <label class="rs-label" for="rs5"><svg viewBox="0 0 24 24" width="40" height="40" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="10" r=".9" fill="currentColor"/><circle cx="15" cy="10" r=".9" fill="currentColor"/><path d="M8 13.5h8c0 2.5-1.8 4.5-4 4.5s-4-2-4-4.5z"/></svg><span class="visually-hidden">5 - Excellent</span></label>
      </fieldset>

      <div class="d-flex align-items-center justify-content-between gap-3 mt-4 pt-4 border-top">
        <p class="mb-0" id="rsOut" aria-live="polite"><span class="fw-bold fs-5 text-primary" data-rs-word>Very poor</span> <span class="wdw-muted small ms-1" data-rs-count>1 of 5</span></p>
        <button type="button" class="btn btn-primary rounded-pill px-4">Continue</button>
      </div>
      </div>
    </div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.

Free to use in personal and commercial projects under the MIT license.