Snippets Contact form

Bootstrap 5 Contact Modal with Floating Label Form

A contact section whose button opens a modal with a floating-label form for name, email and message.

Bootstrap 5 No jQuery Oct 2020 2.4K views

<section class="wdw-stage">
  <div class="container" style="max-width:980px">
    <div class="wdw-card overflow-hidden">
      <div class="row g-0">
        <div class="col-md-6 p-4 p-md-5 d-flex flex-column justify-content-center">
          <span class="wdw-eyebrow">Contact</span>
          <h1 class="display-6 wdw-heading mt-1 mb-3">Let’s talk about your project</h1>
          <p class="wdw-muted mb-4">Tell us a little about what you need and we’ll reply within one business day.</p>
          <div>
            <button type="button" class="btn btn-primary btn-lg rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#cfModal">Contact details</button>
          </div>
        </div>
        <div class="col-md-6 wdw-aurora p-4 p-md-5 d-flex flex-column justify-content-center gap-4">
          <div class="d-flex gap-3 align-items-center"><span class="cf-ico"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="3"/><path d="m4 7 8 6 8-6"/></svg></span><div><div class="small opacity-75">Email</div><div class="fw-semibold">[email protected]</div></div></div>
          <div class="d-flex gap-3 align-items-center"><span class="cf-ico"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2z"/></svg></span><div><div class="small opacity-75">Phone</div><div class="fw-semibold">+1 (555) 014-2290</div></div></div>
          <div class="d-flex gap-3 align-items-center"><span class="cf-ico"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 21s7-6.2 7-11a7 7 0 1 0-14 0c0 4.800 7 11 7 11z"/><circle cx="12" cy="10" r="2.500"/></svg></span><div><div class="small opacity-75">Studio</div><div class="fw-semibold">48 Harbour Street, Portland</div></div></div>
        </div>
      </div>
    </div>
  </div>
  <div class="modal fade" id="cfModal" tabindex="-1" aria-labelledby="cfTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
      <div class="modal-content border-0 shadow-lg" style="border-radius:1.25rem">
        <div class="modal-header border-0 pb-0 px-4 pt-4">
          <div><h2 class="modal-title h4 wdw-heading" id="cfTitle">Send us a message</h2><p class="small wdw-muted mb-0">We usually reply within a day.</p></div>
          <button type="button" class="btn-close align-self-start" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <form id="cfForm" novalidate>
          <div class="modal-body p-4">
            <div class="form-floating mb-3"><input type="text" class="form-control" id="cfName" placeholder="Name" autocomplete="name" required><label for="cfName">Full name</label><div class="invalid-feedback">Please tell us your name.</div></div>
            <div class="form-floating mb-3"><input type="email" class="form-control" id="cfEmail" placeholder="Email" autocomplete="email" required><label for="cfEmail">Email address</label><div class="invalid-feedback">Enter a valid email.</div></div>
            <div class="form-floating"><textarea class="form-control" id="cfMsg" placeholder="Message" style="height:130px" required></textarea><label for="cfMsg">How can we help?</label><div class="invalid-feedback">Write a short message.</div></div>
          </div>
          <div class="modal-footer border-0 px-4 pb-4 pt-0">
            <button type="button" class="btn btn-outline-secondary rounded-pill" data-bs-dismiss="modal">Cancel</button>
            <button type="submit" class="btn btn-primary rounded-pill px-4">Send message</button>
          </div>
        </form>
      </div>
    </div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.