Snippets Animation

Bootstrap 5 Custom Radio Buttons with Hop Animation

Radio options styled as selectable cards, with a playful hop-and-settle animation on the marker when chosen.

Bootstrap 5 No jQuery Mar 2020 2.5K views

<section class="wdw-stage">
  <div class="container" style="max-width: 540px;">
    <form class="wdw-card p-4 p-md-5" id="hop">
      <span class="wdw-eyebrow">Question 1 of 3</span>
      <h2 class="wdw-heading h3 mb-1">Pick your answer</h2>
      <p class="wdw-muted mb-4">Choose one option. The marker hops into place.</p>
      <fieldset class="d-grid gap-3 border-0 p-0 m-0">
        <legend class="visually-hidden">Answer</legend>
        <div>
          <input class="btn-check" type="radio" name="hop" id="hop-a" value="A" checked>
          <label class="btn btn-outline-primary text-start d-flex align-items-center gap-3 hop-label" for="hop-a"><span class="hop-dot" aria-hidden="true"></span><span class="hop-letter">A</span><span class="hop-text flex-grow-1">Design the interface first</span><span class="hop-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.5l4.5 4.5L19 7.5"/></svg></span></label>
        </div>
        <div>
          <input class="btn-check" type="radio" name="hop" id="hop-b" value="B">
          <label class="btn btn-outline-primary text-start d-flex align-items-center gap-3 hop-label" for="hop-b"><span class="hop-dot" aria-hidden="true"></span><span class="hop-letter">B</span><span class="hop-text flex-grow-1">Prototype in code straight away</span><span class="hop-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.5l4.5 4.5L19 7.5"/></svg></span></label>
        </div>
        <div>
          <input class="btn-check" type="radio" name="hop" id="hop-c" value="C">
          <label class="btn btn-outline-primary text-start d-flex align-items-center gap-3 hop-label" for="hop-c"><span class="hop-dot" aria-hidden="true"></span><span class="hop-letter">C</span><span class="hop-text flex-grow-1">Write the content outline</span><span class="hop-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.5l4.5 4.5L19 7.5"/></svg></span></label>
        </div>
      </fieldset>
      <div class="d-flex align-items-center justify-content-between gap-3 mt-4">
        <p class="small wdw-muted mb-0" id="hop-out" aria-live="polite">Step 1 of 3</p>
        <button type="submit" class="btn btn-primary rounded-pill px-4" id="hop-next">Continue</button>
      </div>
    </form>
  </div>
</section>

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