Snippets Radio

Bootstrap 5 Smile Rating Toggle Switch

An animated two-state rating switch where a smiley knob changes its mouth as it slides between Bad and Fun, usable by click, tap or keyboard.

Bootstrap 5 No jQuery Aug 2019 2.7K views

<section class="wdw-stage">
  <div class="container" style="max-width: 760px;">
    <div class="wdw-card overflow-hidden">
      <div class="p-4 p-md-5 text-center">
        <span class="wdw-eyebrow">Quick feedback</span>
        <h1 class="h2 wdw-heading mt-1 mb-1">How was your experience?</h1>
        <p class="wdw-muted mb-0">Slide the switch, or tap a side, to tell us.</p>
      </div>
      <div class="wdw-aurora smile-panel px-3 px-md-5 py-5">
        <form id="smileForm" class="d-flex align-items-center justify-content-center gap-3 gap-md-4" onsubmit="return false">
          <button type="button" class="smile-label active" id="smileBad" data-smile="bad" tabindex="-1">Bad</button>
          <button type="button" role="switch" aria-checked="false" aria-label="Experience rating" aria-describedby="smileStatus" class="smile-track" id="smileSwitch">
            <span class="smile-knob">
              <svg viewBox="0 0 40 40" aria-hidden="true">
                <circle cx="14" cy="16" r="2.4" fill="currentColor"/>
                <circle cx="26" cy="16" r="2.4" fill="currentColor"/>
                <path class="smile-mouth" d="M13 27 Q20 27 27 27" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"/>
              </svg>
            </span>
          </button>
          <button type="button" class="smile-label" id="smileFun" data-smile="fun" tabindex="-1">Fun</button>
        </form>
      </div>
      <div class="p-4 d-flex justify-content-center">
        <p class="smile-chip mb-0" id="smileStatus" role="status" aria-live="polite"><span class="smile-emoji" aria-hidden="true">😕</span> <span id="smileText">Currently: Bad. Sorry to hear that.</span></p>
      </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.