Snippets Form

Bootstrap 5 Contact Form with Gradient Background

A contact form on a full-bleed brand backdrop with floating-label fields, inline validation and a send button. Built with Bootstrap 5 form components and a small vanilla script.

Bootstrap 5 No jQuery Nov 2019 3.7K views

<section class="wdw-stage wdw-aurora cf-stage">
  <div class="container" style="max-width:560px">
    <div class="wdw-card p-4 p-md-5">
      <div class="text-center mb-4">
        <span class="wdw-icon mb-3" style="width:3.25rem;height:3.25rem;border-radius:1rem"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg></span>
        <h1 class="wdw-heading h2 mb-2">Contact us</h1>
        <p class="wdw-muted mb-0">We would love to hear from you. Drop us a line about our products or services and we will reply within one business day.</p>
      </div>
      <form class="cf-form" novalidate>
        <div class="form-floating mb-3">
          <input type="text" class="form-control" id="cf-name" placeholder="Name" autocomplete="name" required>
          <label for="cf-name">Name</label>
          <div class="invalid-feedback">Please enter your name.</div>
        </div>
        <div class="form-floating mb-3">
          <input type="email" class="form-control" id="cf-email" placeholder="Email address" autocomplete="email" required>
          <label for="cf-email">Email address</label>
          <div class="invalid-feedback">Please enter a valid email address.</div>
        </div>
        <div class="form-floating mb-4">
          <textarea class="form-control cf-text" id="cf-msg" placeholder="Message" required></textarea>
          <label for="cf-msg">Message</label>
          <div class="invalid-feedback">Please write a short message.</div>
        </div>
        <button type="submit" class="btn btn-primary rounded-pill w-100">
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/></svg>
          Send message
        </button>
        <div class="alert alert-success d-none mt-3 mb-0" role="status" id="cf-ok">Thanks! Your message is on its way.</div>
      </form>
    </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.