Snippets Contact

Bootstrap 5 Contact Form Examples

Four modern contact form styles: floating labels, split panel with contact details, topic chips and a dark card, each with built-in validation.

Bootstrap 5 No jQuery Jul 2020 3.2K views

<section class="cf-section wdw-stage">
  <div class="container">
    <div class="text-center mx-auto mb-4" style="max-width:32rem">
      <span class="wdw-eyebrow mb-2">Contact forms</span>
      <h2 class="wdw-heading h3 mb-0">Four ways to say hello</h2>
    </div>
    <div class="row g-3 g-lg-4">
      <div class="col-md-6">
        <div class="wdw-card cf-card h-100">
          <form class="cf-form needs-validation d-flex flex-column h-100 p-3 p-lg-4" novalidate>
            <p class="wdw-eyebrow mb-1">Style 1 · Simple</p>
            <h3 class="h5 wdw-heading mb-1">Send us a message</h3>
            <p class="small text-body-secondary mb-3">Questions or feedback. We reply within a day.</p>
            <div class="mb-3"><label for="cf1-email" class="form-label small fw-semibold">Email</label><input type="email" class="form-control" id="cf1-email" placeholder="[email protected]" required><div class="invalid-feedback">Please enter a valid email.</div></div>
            <div class="mb-3"><label for="cf1-msg" class="form-label small fw-semibold">Message</label><textarea class="form-control" id="cf1-msg" rows="6" placeholder="How can we help?" required></textarea><div class="invalid-feedback">Tell us a little more.</div></div>
            <button type="submit" class="btn btn-primary w-100 rounded-pill mt-auto">Send message</button>
            <div class="cf-ok alert alert-success d-none mt-3 mb-0 rounded-3 py-2 small" role="status">Thanks! Your message is on its way.</div>
          </form>
        </div>
      </div>
      <div class="col-md-6">
        <div class="wdw-card cf-card h-100 overflow-hidden">
          <div class="d-flex flex-column h-100">
            <div class="wdw-aurora p-3 p-lg-4">
              <p class="wdw-eyebrow cf-onaurora mb-1">Style 2 · Contact details</p>
              <h3 class="h5 fw-bold mb-3">Let's talk</h3>
              <ul class="cf-contact list-unstyled small mb-0 d-flex flex-column flex-sm-row flex-sm-wrap gap-2 column-gap-3">
                <li class="d-flex gap-2 align-items-center"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="flex-shrink-0"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg>[email protected]</li>
                <li class="d-flex gap-2 align-items-center"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="flex-shrink-0"><path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8 9.9a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2z"/></svg>+1 (555) 014 2290</li>
                <li class="d-flex gap-2 align-items-center"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="flex-shrink-0"><path d="M12 21s7-6.2 7-11.5A7 7 0 0 0 5 9.5C5 14.8 12 21 12 21z"/><circle cx="12" cy="9.5" r="2.5"/></svg>21 Market St, Portland</li>
              </ul>
            </div>
            <form class="cf-form needs-validation d-flex flex-column flex-grow-1 p-3 p-lg-4" novalidate>
              <div class="mb-3"><label for="cf2-name" class="form-label small fw-semibold">Name</label><input type="text" class="form-control" id="cf2-name" placeholder="Jane Cooper" required><div class="invalid-feedback">Your name is required.</div></div>
              <div class="mb-3"><label for="cf2-email" class="form-label small fw-semibold">Email</label><input type="email" class="form-control" id="cf2-email" placeholder="[email protected]" required><div class="invalid-feedback">Please enter a valid email.</div></div>
              <div class="mb-3"><label for="cf2-msg" class="form-label small fw-semibold">Message</label><textarea class="form-control" id="cf2-msg" rows="3" placeholder="How can we help?" required></textarea><div class="invalid-feedback">Please write a message.</div></div>
              <button type="submit" class="btn btn-primary w-100 rounded-pill mt-auto">Send</button>
              <div class="cf-ok alert alert-success d-none mt-3 mb-0 rounded-3 py-2 small" role="status">Message sent. Thank you!</div>
            </form>
          </div>
        </div>
      </div>
      <div class="col-md-6">
        <div class="wdw-card cf-card h-100">
          <form class="cf-form needs-validation d-flex flex-column h-100 p-3 p-lg-4" novalidate>
            <p class="wdw-eyebrow mb-1">Style 3 · Topic chips</p>
            <h3 class="h5 wdw-heading mb-3">What's on your mind?</h3>
            <fieldset class="mb-3">
              <legend class="visually-hidden">Topic</legend>
              <div class="d-flex flex-wrap gap-2">
                <input type="radio" class="btn-check" name="cf3-topic" id="cf3-a" checked><label class="btn btn-outline-secondary cf-chip rounded-pill btn-sm px-3" for="cf3-a">General</label>
                <input type="radio" class="btn-check" name="cf3-topic" id="cf3-b"><label class="btn btn-outline-secondary cf-chip rounded-pill btn-sm px-3" for="cf3-b">Support</label>
                <input type="radio" class="btn-check" name="cf3-topic" id="cf3-c"><label class="btn btn-outline-secondary cf-chip rounded-pill btn-sm px-3" for="cf3-c">Sales</label>
                <input type="radio" class="btn-check" name="cf3-topic" id="cf3-d"><label class="btn btn-outline-secondary cf-chip rounded-pill btn-sm px-3" for="cf3-d">Press</label>
              </div>
            </fieldset>
            <div class="mb-3"><label for="cf3-email" class="form-label small fw-semibold">Email</label><input type="email" class="form-control" id="cf3-email" placeholder="[email protected]" required><div class="invalid-feedback">Please enter a valid email.</div></div>
            <div class="mb-3"><label for="cf3-msg" class="form-label small fw-semibold">Message</label><textarea class="form-control" id="cf3-msg" rows="4" placeholder="Write your message..." required></textarea><div class="invalid-feedback">Please write a message.</div></div>
            <div class="mt-auto d-flex flex-column flex-sm-row align-items-sm-center justify-content-between gap-2">
              <span class="small text-body-secondary order-2 order-sm-1">Average reply: 4 hours</span>
              <button type="submit" class="btn btn-primary rounded-pill px-4 order-1 order-sm-2">Send message</button>
            </div>
            <div class="cf-ok alert alert-success d-none mt-3 mb-0 rounded-3 py-2 small" role="status">Sent! We'll be in touch.</div>
          </form>
        </div>
      </div>
      <div class="col-md-6">
        <div class="wdw-card cf-card h-100">
          <form class="cf-form needs-validation d-flex flex-column h-100 p-3 p-lg-4" novalidate>
            <p class="wdw-eyebrow mb-1">Style 4 · Support ticket</p>
            <h3 class="h5 wdw-heading mb-1">Open a support ticket</h3>
            <p class="small text-body-secondary mb-3">Tell us what's broken and we'll investigate.</p>
            <div class="mb-3">
              <label for="cf4-cat" class="form-label small fw-semibold">Category</label>
              <select class="form-select" id="cf4-cat" required>
                <option value="" selected disabled>Choose a category</option>
                <option>Billing</option><option>Bug report</option><option>Account access</option><option>Feature request</option>
              </select>
              <div class="invalid-feedback">Please choose a category.</div>
            </div>
            <div class="mb-3"><label for="cf4-msg" class="form-label small fw-semibold">Describe the issue</label><textarea class="form-control" id="cf4-msg" rows="3" placeholder="What happened?" required></textarea><div class="invalid-feedback">Please describe the issue.</div></div>
            <div class="mb-3">
              <label for="cf4-file" class="form-label small fw-semibold">Attachment <span class="fw-normal text-body-secondary">(optional)</span></label>
              <input type="file" class="form-control" id="cf4-file">
            </div>
            <button type="submit" class="btn btn-primary w-100 rounded-pill mt-auto">Submit ticket</button>
            <div class="cf-ok alert alert-success d-none mt-3 mb-0 rounded-3 py-2 small" role="status">Ticket created. We'll email you shortly.</div>
          </form>
        </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.