Snippets Modal

Bootstrap 5 Newsletter Subscribe Modal

A newsletter sign-up modal with a brand header, short pitch, validated email field and a confirmation state. It opens from a button and returns focus on close.

Bootstrap 5 No jQuery Nov 2019 2.1K views

<section class="wdw-stage">
  <div class="container text-center" style="max-width:520px">
    <span class="wdw-eyebrow">Newsletter modal</span>
    <h1 class="wdw-heading h3 mt-1 mb-3">Show the sign-up in a modal</h1>
    <button type="button" class="btn btn-primary rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#subModal">Open newsletter modal</button>
  </div>
</section>
<div class="modal fade" id="subModal" tabindex="-1" aria-labelledby="subTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" style="max-width:480px">
    <div class="modal-content border-0 shadow-lg overflow-hidden" style="border-radius:1.5rem">
      <div class="wdw-aurora px-4 pt-4 pb-5 text-center">
        <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>
        <span class="d-inline-flex align-items-center justify-content-center rounded-circle bg-white bg-opacity-25 mb-3" style="width:56px;height:56px"><svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="3"/><path d="m4 8 8 5.5L20 8"/></svg></span>
        <h2 class="h4 fw-bolder mb-0" id="subTitle">Subscribe to our newsletter</h2>
      </div>
      <div class="modal-body p-4 pt-4">
        <p class="wdw-muted text-center">Get the latest news, updates and amazing offers delivered straight to your inbox every week.</p>
        <form id="subForm" novalidate>
          <label class="form-label small fw-semibold" for="subEmail">Email address</label>
          <input type="email" class="form-control mb-1" id="subEmail" placeholder="[email protected]" required autocomplete="email">
          <div class="invalid-feedback">Please enter a valid email address.</div>
          <button class="btn btn-primary rounded-pill w-100 mt-3" type="submit">Subscribe</button>
          <p class="small wdw-muted text-center mt-3 mb-0" id="subMsg" role="status">No spam. Unsubscribe anytime.</p>
        </form>
      </div>
    </div>
  </div>
</div>

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.