Snippets Animation

Bootstrap 5 Pick Two of Three Toggle Cards

A pick-two selector where three switch cards (social life, work, sleep) allow only two to be on at once, turning off the oldest choice when a third is selected.

Bootstrap 5 No jQuery Aug 2019 2.2K views

<section class="wdw-stage">
  <div class="container" style="max-width:760px">
    <div class="text-center mb-4 mb-md-5">
      <span class="wdw-eyebrow mb-2">The life paradox</span>
      <h1 class="wdw-heading h2 mb-2">Pick two. You can’t have all three.</h1>
      <p class="wdw-muted mb-0" id="lpHint" aria-live="polite">Social life and Sleep are on. Switch one on and another turns off.</p>
    </div>
    <fieldset class="row g-3" id="lifeParadox">
      <legend class="visually-hidden">Choose two of three</legend>
      <div class="col-12 col-md-4">
        <input type="checkbox" class="btn-check lp-input" id="lp-social" name="social" autocomplete="off" checked>
        <label class="lp-card wdw-card h-100 d-flex flex-column p-4" for="lp-social">
          <span class="d-flex align-items-center justify-content-between mb-4">
            <span class="wdw-icon"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 21v-2a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8"/></svg></span>
            <span class="lp-switch" aria-hidden="true"></span>
          </span>
          <strong class="fs-5 text-body-emphasis mb-1">Social life</strong>
          <span class="wdw-muted small">Friends, dinners and last-minute plans</span>
        </label>
      </div>
      <div class="col-12 col-md-4">
        <input type="checkbox" class="btn-check lp-input" id="lp-work" name="work" autocomplete="off">
        <label class="lp-card wdw-card h-100 d-flex flex-column p-4" for="lp-work">
          <span class="d-flex align-items-center justify-content-between mb-4">
            <span class="wdw-icon"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7h18v13H3zM8 7V4h8v3M3 13h18"/></svg></span>
            <span class="lp-switch" aria-hidden="true"></span>
          </span>
          <strong class="fs-5 text-body-emphasis mb-1">Work</strong>
          <span class="wdw-muted small">Deadlines, deep focus and shipping things</span>
        </label>
      </div>
      <div class="col-12 col-md-4">
        <input type="checkbox" class="btn-check lp-input" id="lp-sleep" name="sleep" autocomplete="off" checked>
        <label class="lp-card wdw-card h-100 d-flex flex-column p-4" for="lp-sleep">
          <span class="d-flex align-items-center justify-content-between mb-4">
            <span class="wdw-icon"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg></span>
            <span class="lp-switch" aria-hidden="true"></span>
          </span>
          <strong class="fs-5 text-body-emphasis mb-1">Sleep</strong>
          <span class="wdw-muted small">Eight hours and a quiet morning</span>
        </label>
      </div>
    </fieldset>
  </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.