Snippets Buttons

Bootstrap 5 Toggle Switch Styles (CSS Only)

A gallery of six animated toggle switch styles built on native checkboxes: classic, outline, check and cross, inline labels, stretchy and status dot.

Bootstrap 5 No jQuery Feb 2020 2K views

<section class="wdw-stage">
  <div class="container" style="max-width:1000px">
    <div class="text-center mb-5">
      <span class="wdw-eyebrow">UI controls</span>
      <h2 class="wdw-heading display-6 mb-2">Toggle switches</h2>
      <p class="wdw-muted mb-0">Six pure-CSS switch styles built on real checkboxes. Click to try them.</p>
    </div>
    <div class="row g-4">
      <div class="col-md-6 col-lg-4">
        <div class="wdw-card h-100 p-4 d-flex flex-column align-items-center text-center gap-3">
          <div class="tg-demo d-flex align-items-center justify-content-center w-100 rounded-4 bg-body-tertiary">
            <span class="tg tg-classic">
              <input type="checkbox" role="switch" id="tg-classic" class="tg-input" checked aria-labelledby="tg-classic-n">
              <label for="tg-classic" class="tg-track"><span class="visually-hidden">Classic</span><span class="tg-thumb"></span></label>
            </span>
          </div>
          <div>
            <h3 class="h6 fw-bold mb-1 text-body-emphasis" id="tg-classic-n">Classic</h3>
            <p class="small wdw-muted mb-0">Smooth thumb slide with a color shift.</p>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-4">
        <div class="wdw-card h-100 p-4 d-flex flex-column align-items-center text-center gap-3">
          <div class="tg-demo d-flex align-items-center justify-content-center w-100 rounded-4 bg-body-tertiary">
            <span class="tg tg-outline">
              <input type="checkbox" role="switch" id="tg-outline" class="tg-input" aria-labelledby="tg-outline-n">
              <label for="tg-outline" class="tg-track"><span class="visually-hidden">Outline</span><span class="tg-thumb"></span></label>
            </span>
          </div>
          <div>
            <h3 class="h6 fw-bold mb-1 text-body-emphasis" id="tg-outline-n">Outline</h3>
            <p class="small wdw-muted mb-0">Quiet outlined track for minimal interfaces.</p>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-4">
        <div class="wdw-card h-100 p-4 d-flex flex-column align-items-center text-center gap-3">
          <div class="tg-demo d-flex align-items-center justify-content-center w-100 rounded-4 bg-body-tertiary">
            <span class="tg tg-icon">
              <input type="checkbox" role="switch" id="tg-icon" class="tg-input" checked aria-labelledby="tg-icon-n">
              <label for="tg-icon" class="tg-track"><span class="visually-hidden">Check & cross</span><svg class="tg-ic tg-ic-on" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg><svg class="tg-ic tg-ic-off" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17"/></svg><span class="tg-thumb"></span></label>
            </span>
          </div>
          <div>
            <h3 class="h6 fw-bold mb-1 text-body-emphasis" id="tg-icon-n">Check & cross</h3>
            <p class="small wdw-muted mb-0">Clear yes/no state with an icon in the thumb.</p>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-4">
        <div class="wdw-card h-100 p-4 d-flex flex-column align-items-center text-center gap-3">
          <div class="tg-demo d-flex align-items-center justify-content-center w-100 rounded-4 bg-body-tertiary">
            <span class="tg tg-label">
              <input type="checkbox" role="switch" id="tg-label" class="tg-input" checked aria-labelledby="tg-label-n">
              <label for="tg-label" class="tg-track"><span class="visually-hidden">Inline labels</span><span class="tg-txt tg-txt-on" aria-hidden="true">ON</span><span class="tg-txt tg-txt-off" aria-hidden="true">OFF</span><span class="tg-thumb"></span></label>
            </span>
          </div>
          <div>
            <h3 class="h6 fw-bold mb-1 text-body-emphasis" id="tg-label-n">Inline labels</h3>
            <p class="small wdw-muted mb-0">State text sits inside the track.</p>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-4">
        <div class="wdw-card h-100 p-4 d-flex flex-column align-items-center text-center gap-3">
          <div class="tg-demo d-flex align-items-center justify-content-center w-100 rounded-4 bg-body-tertiary">
            <span class="tg tg-squish">
              <input type="checkbox" role="switch" id="tg-squish" class="tg-input" aria-labelledby="tg-squish-n">
              <label for="tg-squish" class="tg-track"><span class="visually-hidden">Stretchy</span><span class="tg-thumb"></span></label>
            </span>
          </div>
          <div>
            <h3 class="h6 fw-bold mb-1 text-body-emphasis" id="tg-squish-n">Stretchy</h3>
            <p class="small wdw-muted mb-0">Thumb stretches mid-move for a tactile feel.</p>
          </div>
        </div>
      </div>
      <div class="col-md-6 col-lg-4">
        <div class="wdw-card h-100 p-4 d-flex flex-column align-items-center text-center gap-3">
          <div class="tg-demo d-flex align-items-center justify-content-center w-100 rounded-4 bg-body-tertiary">
            <span class="tg tg-dot">
              <input type="checkbox" role="switch" id="tg-dot" class="tg-input" checked aria-labelledby="tg-dot-n">
              <label for="tg-dot" class="tg-track"><span class="visually-hidden">Status dot</span><span class="tg-thumb"></span></label>
            </span>
          </div>
          <div>
            <h3 class="h6 fw-bold mb-1 text-body-emphasis" id="tg-dot-n">Status dot</h3>
            <p class="small wdw-muted mb-0">Compact switch with a pulsing live indicator.</p>
          </div>
        </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.