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.
<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>
/* Web Designer Wall library style — shared base for every Bootstrap 5 snippet.
Indigo accent, Plus Jakarta Sans, soft cards, pill buttons. Works in light and dark. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root,
[data-bs-theme="light"] {
--wdw-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--bs-body-font-family: var(--wdw-font);
--bs-primary: #4f46e5;
--bs-primary-rgb: 79, 70, 229;
--bs-primary-text-emphasis: #3730a3;
--bs-primary-bg-subtle: #eef2ff;
--bs-primary-border-subtle: #c7d2fe;
--bs-link-color: #4f46e5;
--bs-link-color-rgb: 79, 70, 229;
--bs-link-hover-color: #4338ca;
--bs-link-hover-color-rgb: 67, 56, 202;
--bs-focus-ring-color: rgba(79, 70, 229, 0.25);
--bs-border-radius: 0.75rem;
--bs-border-radius-lg: 1rem;
--bs-border-radius-xl: 1.25rem;
--wdw-radius-card: 1.25rem;
--wdw-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 40, 0.22);
--wdw-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
--wdw-stage: #f5f6fb;
}
[data-bs-theme="dark"] {
--bs-primary: #818cf8;
--bs-primary-rgb: 129, 140, 248;
--bs-primary-text-emphasis: #c7d2fe;
--bs-primary-bg-subtle: rgba(129, 140, 248, 0.14);
--bs-primary-border-subtle: rgba(129, 140, 248, 0.35);
--bs-link-color: #a5b4fc;
--bs-link-color-rgb: 165, 180, 252;
--bs-link-hover-color: #c7d2fe;
--bs-link-hover-color-rgb: 199, 210, 254;
--bs-focus-ring-color: rgba(129, 140, 248, 0.35);
--wdw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
--wdw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
--wdw-stage: #0f1117;
}
body { font-family: var(--wdw-font); -webkit-font-smoothing: antialiased; }
/* Bootstrap compiles its blue into these components; point them at the accent. */
.btn-primary {
--bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
--bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
--bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-hover-color: #0f1117; --bs-btn-active-color: #0f1117; }
.btn-outline-primary {
--bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
--bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn { --bs-btn-font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-radius: .75rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.nav { --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-emphasis-color); }
.pagination { --bs-pagination-active-bg: var(--bs-primary); --bs-pagination-active-border-color: var(--bs-primary); --bs-pagination-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }
.list-group { --bs-list-group-active-bg: var(--bs-primary); --bs-list-group-active-border-color: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); border-radius: .875rem; box-shadow: var(--wdw-shadow-sm); }
.accordion { --bs-accordion-active-bg: var(--bs-primary-bg-subtle); --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.badge { font-weight: 600; }
/* Library building blocks — use these instead of re-inventing them per snippet. */
.wdw-stage { min-height: 100vh; display: flex; align-items: center; background: var(--wdw-stage); padding-block: 3rem; }
.wdw-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--wdw-radius-card); box-shadow: var(--wdw-shadow); }
.wdw-card-sm { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: 1rem; box-shadow: var(--wdw-shadow-sm); }
.wdw-aurora { position: relative; color: #fff; background: radial-gradient(60% 55% at 100% 0, #818cf8 0, transparent 70%), radial-gradient(65% 60% at 0 100%, #ec4899 0, transparent 65%), #1e1b4b; }
.wdw-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-primary); }
.wdw-heading { font-weight: 800; letter-spacing: -.02em; color: var(--bs-emphasis-color); }
.wdw-muted { color: var(--bs-secondary-color); }
.wdw-icon { width: 2.75rem; height: 2.75rem; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: .875rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
/* Component */
.fm-social { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: rgba(255,255,255,.16); text-decoration: none; transition: background-color .2s; }
.fm-social:hover { background: rgba(255,255,255,.3); color: #fff; }
.fm-social:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.fm-seg .btn { min-height: 36px; border: 0; color: var(--bs-secondary-color); font-weight: 500; }
.fm-seg .btn:hover { color: var(--bs-body-color); }
.fm-seg .btn-check:checked + .btn { background: var(--bs-primary); color: #fff; }
.fm-seg .btn-check:focus-visible + .btn { box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .5); }
.fm-stage .form-floating > label { color: var(--bs-secondary-color); }
.fm-stage .form-control, .fm-stage .form-select { transition: border-color .2s, background-color .2s, box-shadow .2s; }
.fm-outline .form-control, .fm-outline .form-select { border-radius: .75rem; }
.fm-filled .form-control, .fm-filled .form-select { border: 0; border-radius: .75rem; background-color: var(--bs-secondary-bg); }
.fm-filled .form-control:focus, .fm-filled .form-select:focus { background-color: var(--bs-body-bg); box-shadow: 0 0 0 2px var(--bs-primary); }
.fm-filled .was-validated .form-control:invalid, .fm-filled.was-validated .form-control:invalid, .fm-filled.was-validated .form-select:invalid { box-shadow: 0 0 0 2px var(--bs-form-invalid-border-color); }
.fm-line .form-control, .fm-line .form-select { border: 0; border-bottom: 2px solid var(--bs-border-color); border-radius: 0; background-color: transparent; box-shadow: none; padding-left: 0; }
.fm-line .form-select { padding-right: 2.25rem; }
.fm-line .form-floating > label { padding-left: 0; padding-right: 2.25rem; max-width: 100%; }
.fm-line .form-control:focus, .fm-line .form-select:focus { border-bottom-color: var(--bs-primary); }
.fm-line.was-validated .form-control:invalid, .fm-line.was-validated .form-select:invalid { border-bottom-color: var(--bs-form-invalid-border-color); }
(function () {
function initFormStyles() {
var form = document.getElementById('fmForm');
if (!form) return;
document.querySelectorAll('input[name=fmStyle]').forEach(function (r) {
r.addEventListener('change', function () { form.className = r.value + (form.classList.contains('was-validated') ? ' was-validated' : ''); });
});
var ok = document.getElementById('fmOk');
form.addEventListener('submit', function (e) {
e.preventDefault();
form.classList.add('was-validated');
var valid = form.checkValidity();
ok.classList.toggle('d-none', !valid);
if (valid) { form.reset(); form.classList.remove('was-validated'); ok.classList.remove('d-none'); }
});
}
initFormStyles();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.