Snippets Checkbox

Bootstrap 5 Custom Checkbox and Radio Cards

Selectable checkbox and radio rows with a clear checked state and an animated mark. Built on native inputs, so keyboard and screen readers work.

Bootstrap 5 No jQuery Aug 2019 2.2K views

<section class="wdw-stage">
  <div class="container" style="max-width:760px">
    <div class="wdw-card p-4 p-md-5">
      <form>
        <div class="row g-4 g-md-5">
          <div class="col-md-6"><fieldset>
          <legend class="wdw-heading h5 mb-1">Notifications</legend>
          <p class="small text-body-secondary mb-3">Choose what lands in your inbox.</p>
          <div class="d-grid gap-3">
          <div class="position-relative">
            <input type="checkbox" class="visually-hidden mi-input" id="miOpt1" checked>
            <label class="mi-row" for="miOpt1"><span class="wdw-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18v12H3z"/><path d="m3 7 9 6 9-6"/></svg></span><span class="flex-grow-1"><span class="d-block fw-semibold text-body-emphasis">Email updates</span><span class="d-block small text-body-secondary">Product news and release notes</span></span><span class="mi-mark mi-check" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12.5 4.5 4.5L19 7.500"/></svg></span></label>
          </div>
          <div class="position-relative">
            <input type="checkbox" class="visually-hidden mi-input" id="miOpt2">
            <label class="mi-row" for="miOpt2"><span class="wdw-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4"/></svg></span><span class="flex-grow-1"><span class="d-block fw-semibold text-body-emphasis">Weekly digest</span><span class="d-block small text-body-secondary">One summary every Monday morning</span></span><span class="mi-mark mi-check" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12.5 4.5 4.5L19 7.500"/></svg></span></label>
          </div>
          </div>
        </fieldset></div>
          <div class="col-md-6"><fieldset>
          <legend class="wdw-heading h5 mb-1">Make my profile public?</legend>
          <p class="small text-body-secondary mb-3">You can change this at any time.</p>
          <div class="d-grid gap-3">
          <div class="position-relative">
            <input type="radio" class="visually-hidden mi-input" name="miPublic" id="miYes" checked>
            <label class="mi-row" for="miYes"><span class="wdw-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18z"/></svg></span><span class="flex-grow-1"><span class="d-block fw-semibold text-body-emphasis">Yes, public</span><span class="d-block small text-body-secondary">Anyone can find and view your profile</span></span><span class="mi-mark mi-radio" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12.5 4.5 4.5L19 7.500"/></svg></span></label>
          </div>
          <div class="position-relative">
            <input type="radio" class="visually-hidden mi-input" name="miPublic" id="miNo">
            <label class="mi-row" for="miNo"><span class="wdw-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="11" width="16" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg></span><span class="flex-grow-1"><span class="d-block fw-semibold text-body-emphasis">No, private</span><span class="d-block small text-body-secondary">Only people you approve can see it</span></span><span class="mi-mark mi-radio" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12.5 4.5 4.5L19 7.500"/></svg></span></label>
          </div>
          </div>
        </fieldset></div>
        </div>
      </form>
    </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.