Snippets Newsletter

Bootstrap 5 Newsletter Subscription Form

A newsletter sign-up card that asks a yes or no question, then reveals an email field and a success message with validation.

Bootstrap 5 No jQuery Jul 2019 2.1K views

<section class="wdw-stage">
  <div class="container" style="max-width:640px">
    <div class="nl wdw-aurora rounded-5 p-4 p-sm-5 text-center overflow-hidden">
      <div class="nl-step" data-step="ask">
        <span class="nl-icon mx-auto mb-4"><i class="bi bi-envelope-paper-heart"></i></span>
        <h2 class="nl-title fw-bold mb-2">Do you want to receive our weekly newsletter?</h2>
        <p class="nl-sub mb-4">One short email every Friday. Design news, new components and no spam.</p>
        <div class="d-flex flex-column flex-sm-row gap-3 justify-content-center">
          <button type="button" class="btn btn-light rounded-pill px-4 fw-semibold" data-go="form">Yes, sign me up</button>
          <button type="button" class="btn btn-outline-light rounded-pill px-4" data-go="later">Maybe later</button>
        </div>
      </div>
      <form class="nl-step" data-step="form" novalidate hidden>
        <h2 class="nl-title fw-bold mb-2">Where should we send it?</h2>
        <p class="nl-sub mb-4">Enter your email and you are in.</p>
        <div class="nl-field mb-2">
          <label for="nlEmail" class="visually-hidden">Email address</label>
          <input id="nlEmail" type="email" class="form-control rounded-pill" placeholder="[email protected]" autocomplete="email" required>
          <button type="submit" class="btn btn-light rounded-pill fw-semibold">Subscribe</button>
        </div>
        <p class="nl-error small mb-0" id="nlError" role="alert" hidden>Please enter a valid email address.</p>
        <button type="button" class="btn btn-link link-light link-underline-opacity-50 btn-sm mt-3" data-go="ask">Back</button>
      </form>
      <div class="nl-step" data-step="done" hidden>
        <span class="nl-icon nl-ok mx-auto mb-4"><i class="bi bi-check-lg"></i></span>
        <h2 class="nl-title fw-bold mb-2">You are subscribed</h2>
        <p class="nl-sub mb-0" role="status">Watch your inbox this Friday for the first issue.</p>
      </div>
      <div class="nl-step" data-step="later" hidden>
        <h2 class="nl-title fw-bold mb-2">No problem</h2>
        <p class="nl-sub mb-4">You can subscribe any time from the footer.</p>
        <button type="button" class="btn btn-outline-light rounded-pill px-4" data-go="ask">Changed my mind</button>
      </div>
    </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.