Snippets Form

Bootstrap 5 Contact Form Styles (Outlined, Filled, Underline)

A contact form with floating labels, validation and a switcher that restyles it as outlined, filled or underline. Submitting shows a confirmation message.

Bootstrap 5 No jQuery Sep 2019 1.6K views

<section class="wdw-stage fm-stage">
  <div class="container" style="max-width: 1000px;">
    <div class="card wdw-card overflow-hidden"><div class="row g-0">
      <aside class="col-lg-5 wdw-aurora text-white p-4 p-md-5 d-flex flex-column">
        <h1 class="h2 fw-bold mb-2">Get in touch</h1>
        <p class="mb-4 opacity-75">Tell us about your project. We reply within one business day.</p>
        <ul class="list-unstyled d-grid gap-3 mb-4">
          <li class="d-flex gap-3 align-items-start"><svg width="20" height="20" viewBox="0 0 16 16" fill="currentColor" class="flex-shrink-0" aria-hidden="true"><path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v.217l-8 4.8-8-4.8zm0 1.383v6.617a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5.383l-7.515 4.51a1 1 0 0 1-1.03 0z"/></svg><span><span class="d-block small opacity-75">Email</span>[email protected]</span></li>
          <li class="d-flex gap-3 align-items-start"><svg width="20" height="20" viewBox="0 0 16 16" fill="currentColor" class="flex-shrink-0" aria-hidden="true"><path d="M3.654 1.328a.678.678 0 0 0-1.015-.063L1.605 2.3c-.483.484-.661 1.169-.45 1.77a17.6 17.6 0 0 0 4.168 6.608 17.6 17.6 0 0 0 6.608 4.168c.601.211 1.286.033 1.77-.45l1.034-1.034a.678.678 0 0 0-.063-1.015l-2.307-1.794a.68.68 0 0 0-.58-.122l-2.19.547a1.75 1.75 0 0 1-1.657-.459L5.482 8.062a1.75 1.75 0 0 1-.46-1.657l.548-2.19a.68.68 0 0 0-.122-.58z"/></svg><span><span class="d-block small opacity-75">Phone</span>+1 (555) 014-2290</span></li>
          <li class="d-flex gap-3 align-items-start"><svg width="20" height="20" viewBox="0 0 16 16" fill="currentColor" class="flex-shrink-0" aria-hidden="true"><path d="M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10m0-7a3 3 0 1 1 0-6 3 3 0 0 1 0 6"/></svg><span><span class="d-block small opacity-75">Studio</span>42 Market Street, San Francisco</span></li>
          <li class="d-flex gap-3 align-items-start"><svg width="20" height="20" viewBox="0 0 16 16" fill="currentColor" class="flex-shrink-0" aria-hidden="true"><path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71z"/><path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0"/></svg><span><span class="d-block small opacity-75">Hours</span>Mon to Fri, 9:00 to 18:00</span></li>
        </ul>
        <div class="d-flex gap-2 mt-auto">
          <a href="#" class="fm-social" aria-label="X"><svg width="18" height="18" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865z"/></svg></a>
          <a href="#" class="fm-social" aria-label="LinkedIn"><svg width="18" height="18" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854zm4.943 12.248V6.169H2.542v7.225zm-1.2-8.212c.837 0 1.358-.554 1.358-1.248-.015-.709-.52-1.248-1.342-1.248S2.4 3.226 2.4 3.934c0 .694.521 1.248 1.327 1.248zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 1.193v.025h-.016l.016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225z"/></svg></a>
          <a href="#" class="fm-social" aria-label="Instagram"><svg width="18" height="18" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C5.829 0 5.556.01 4.703.048 3.85.088 3.269.222 2.76.42a3.9 3.9 0 0 0-1.417.923A3.9 3.9 0 0 0 .42 2.76C.222 3.268.087 3.85.048 4.7.01 5.555 0 5.827 0 8.001c0 2.172.01 2.444.048 3.297.04.852.174 1.433.372 1.942.205.526.478.972.923 1.417.444.445.89.719 1.416.923.51.198 1.09.333 1.942.372C5.555 15.99 5.827 16 8 16s2.444-.01 3.298-.048c.851-.04 1.434-.174 1.943-.372a3.9 3.9 0 0 0 1.416-.923c.445-.445.718-.891.923-1.417.197-.509.332-1.09.372-1.942C15.99 10.445 16 10.173 16 8s-.01-2.445-.048-3.299c-.04-.851-.175-1.433-.372-1.941a3.9 3.9 0 0 0-.923-1.417A3.9 3.9 0 0 0 13.24.42c-.51-.198-1.092-.333-1.943-.372C10.443.01 10.172 0 7.998 0zm-.717 1.442h.718c2.136 0 2.389.007 3.232.046.78.035 1.204.166 1.486.275.373.145.64.319.92.599s.453.546.598.92c.11.281.24.705.275 1.485.039.843.047 1.096.047 3.231s-.008 2.389-.047 3.232c-.035.78-.166 1.203-.275 1.485a2.5 2.5 0 0 1-.599.919c-.28.28-.546.453-.92.598-.28.11-.704.24-1.485.276-.843.038-1.096.047-3.232.047s-2.39-.009-3.233-.047c-.78-.036-1.203-.166-1.485-.276a2.5 2.5 0 0 1-.92-.598 2.5 2.5 0 0 1-.6-.92c-.109-.281-.24-.705-.275-1.485-.038-.843-.046-1.096-.046-3.233s.008-2.388.046-3.231c.036-.78.166-1.204.276-1.486.145-.373.319-.64.599-.92s.546-.453.92-.598c.282-.11.705-.24 1.485-.276.738-.034 1.024-.044 2.515-.045zm4.988 1.328a.96.96 0 1 0 0 1.92.96.96 0 0 0 0-1.92m-4.27 1.122a4.109 4.109 0 1 0 0 8.217 4.109 4.109 0 0 0 0-8.217m0 1.441a2.667 2.667 0 1 1 0 5.334 2.667 2.667 0 0 1 0-5.334"/></svg></a>
        </div>
      </aside>
      <div class="col-lg-7"><div class="p-4 p-md-5">
        <div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-4">
          <h2 class="h5 fw-semibold text-body-emphasis mb-0">Send a message</h2>
          <div class="fm-seg d-inline-flex p-1 rounded-pill bg-body-secondary" role="group" aria-label="Form style">
            <input type="radio" class="btn-check" name="fmStyle" id="fmS1" value="fm-outline" checked>
            <label class="btn btn-sm rounded-pill px-3 d-inline-flex align-items-center justify-content-center" for="fmS1">Outlined</label>
            <input type="radio" class="btn-check" name="fmStyle" id="fmS2" value="fm-filled">
            <label class="btn btn-sm rounded-pill px-3 d-inline-flex align-items-center justify-content-center" for="fmS2">Filled</label>
            <input type="radio" class="btn-check" name="fmStyle" id="fmS3" value="fm-line">
            <label class="btn btn-sm rounded-pill px-3 d-inline-flex align-items-center justify-content-center" for="fmS3">Underline</label>
          </div>
        </div>
        <form id="fmForm" class="fm-outline" novalidate>
          <div class="row g-3">
            <div class="col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="fmName" placeholder="Name" required><label for="fmName">Your name</label><div class="invalid-feedback">Name is required.</div></div></div>
            <div class="col-sm-6"><div class="form-floating"><input type="email" class="form-control" id="fmEmail" placeholder="Email" required><label for="fmEmail">Email</label><div class="invalid-feedback">Enter a valid email.</div></div></div>
            <div class="col-12"><div class="form-floating"><select class="form-select" id="fmTopic" required><option value="" selected disabled>Choose a topic</option><option>New project</option><option>Support</option><option>Partnership</option></select><label for="fmTopic">Topic</label><div class="invalid-feedback">Please choose a topic.</div></div></div>
            <div class="col-12"><div class="form-floating"><textarea class="form-control" id="fmMsg" placeholder="Message" style="height:130px; min-height:130px" required></textarea><label for="fmMsg">Message</label><div class="invalid-feedback">Please add a message.</div></div></div>
            <div class="col-12">
              <button type="submit" class="btn btn-primary btn-lg w-100 rounded-pill">Send message</button>
              <p id="fmOk" class="text-success small text-center mt-3 mb-0 d-none" role="status">Message sent. Thank you!</p>
            </div>
          </div>
        </form>
      </div></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.