Snippets Email

Bootstrap 5 Header Newsletter Bar (Show/Hide)

A newsletter sign-up bar that slides open above a full-bleed editorial hero, with inline validation and a skip action that collapses it away. A small button brings it back.

Bootstrap 5 No jQuery Nov 2019 2.1K views

<section class="wdw-stage">
  <div class="container" style="max-width:960px">
    <div class="wdw-card overflow-hidden" id="nl-demo">
      <div class="collapse show" id="nlPanel">
        <div class="nl-bar p-4 p-md-4">
          <form class="row g-3 align-items-center" id="nlForm" novalidate>
            <div class="col-lg-5 d-flex align-items-center gap-3">
              <span class="wdw-icon" aria-hidden="true">
                <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="3"/><path d="m4 8 8 5.5L20 8"/></svg>
              </span>
              <div>
                <h2 class="h6 fw-bold mb-0">Get the weekly dispatch</h2>
                <p class="small wdw-muted mb-0">One thoughtful story, every Friday.</p>
              </div>
            </div>
            <div class="col-lg-7">
              <div class="input-group">
                <label class="visually-hidden" for="nlEmail">Email address</label>
                <input type="email" class="form-control rounded-start-pill ps-4" id="nlEmail" placeholder="[email protected]" required autocomplete="email">
                <button class="btn btn-primary rounded-end-pill px-4" type="submit">Subscribe</button>
                <button class="btn btn-link link-secondary ms-1 px-2" type="button" id="nlSkip" aria-label="Skip newsletter">Skip</button>
              </div>
              <div class="small mt-2 d-none" id="nlMsg" role="status"></div>
            </div>
          </form>
        </div>
      </div>
      <div class="nl-hero d-flex align-items-end text-white">
        <div class="p-4 p-md-5 position-relative">
          <button class="btn btn-light btn-sm rounded-pill mb-4 d-none" type="button" id="nlOpen" aria-controls="nlPanel" aria-expanded="false">Show newsletter</button>
          <span class="wdw-eyebrow text-white-50 d-block mb-2">Essay</span>
          <h1 class="display-5 fw-bolder mb-3" style="letter-spacing:-.03em">Going outside is highly overrated.</h1>
          <p class="mb-0 col-lg-8 opacity-75">"I created the OASIS because I never felt at home in the real world. I didn't know how to connect with the people there. I was afraid, for all of my life."</p>
        </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.

Free to use in personal and commercial projects under the MIT license.