Snippets Buttons

Bootstrap 5 Discount Modal with Promo Code

A discount modal opened from a button, with a bold percentage header, a copyable promo code and a call to action.

Bootstrap 5 No jQuery Dec 2019 2.9K views

<section class="wdw-stage">
  <div class="container text-center" style="max-width:640px">
    <button type="button" class="btn btn-primary btn-lg rounded-pill px-5" data-bs-toggle="modal" data-bs-target="#discountModal">Get my discount</button>
  </div>

  <div class="modal fade" id="discountModal" tabindex="-1" aria-labelledby="discountTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" style="max-width:520px">
      <div class="modal-content border-0 overflow-hidden" style="border-radius:1.25rem">
        <div class="wdw-aurora text-center px-4 pt-5 pb-5 position-relative">
          <button type="button" class="btn-close btn-close-white position-absolute top-0 end-0 m-3" data-bs-dismiss="modal" aria-label="Close"></button>
          <div class="fw-bold lh-1 wdw-big">20%</div>
          <div class="text-white-50 mt-2 fs-5">off your first order</div>
        </div>
        <div class="modal-body p-4 p-md-5 text-center">
          <h2 class="h4 wdw-heading" id="discountTitle">Your discount code</h2>
          <p class="wdw-muted">Valid for 7 days on orders over $30.</p>
          <div class="input-group mb-3">
            <input type="text" class="form-control text-center fw-bold rounded-start-pill" id="discountCode" value="WELCOME20" readonly aria-label="Discount code">
            <button type="button" class="btn btn-outline-primary rounded-end-pill px-4" id="copyCode">Copy</button>
          </div>
          <div class="visually-hidden" role="status" aria-live="polite" id="copyStatus"></div>
          <button type="button" class="btn btn-primary rounded-pill w-100" data-bs-dismiss="modal">Start shopping</button>
        </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.