Bootstrap 5 Contact Form with Map
A contact section pairing a map panel and address card with a floating-label message form and direct phone and email links.
<section class="wdw-stage">
<div class="container" style="max-width:1040px">
<div class="wdw-card overflow-hidden">
<div class="row g-0">
<div class="col-lg-6 wdw-map position-relative">
<svg class="wdw-map-svg" viewBox="0 0 600 700" preserveAspectRatio="xMidYMid slice" role="img" aria-label="Stylised map showing our office location">
<rect width="600" height="700" class="m-land"/>
<path class="m-water" d="M-20 560 C 120 520 200 600 330 580 S 520 520 640 560 V 720 H -20Z"/>
<path class="m-park" d="M40 70h150a20 20 0 0 1 20 20v110a20 20 0 0 1-20 20H40a20 20 0 0 1-20-20V90a20 20 0 0 1 20-20z"/>
<path class="m-park" d="M400 380h150a20 20 0 0 1 20 20v70a20 20 0 0 1-20 20H400a20 20 0 0 1-20-20v-70a20 20 0 0 1 20-20z"/>
<g class="m-road" fill="none" stroke-linecap="round">
<path d="M-10 250 H 610" stroke-width="16"/>
<path d="M-10 430 L 610 360" stroke-width="12"/>
<path d="M240 -10 V 710" stroke-width="16"/>
<path d="M420 -10 L 380 710" stroke-width="10"/>
<path d="M90 -10 L 120 540" stroke-width="8"/>
<path d="M-10 120 H 240" stroke-width="7"/>
<path d="M240 330 H 610" stroke-width="7"/>
<path d="M500 -10 V 360" stroke-width="7"/>
<path d="M120 470 H 380" stroke-width="7"/>
</g>
<g class="wdw-mpin" transform="translate(240 250)">
<circle r="46" class="m-halo"/>
<circle r="22" class="m-halo2"/>
<path d="M0 -4 C -18 -30 -22 -44 -22 -54 a22 22 0 0 1 44 0 c0 10 -4 24 -22 50z" transform="translate(0 4)" class="m-pin-body"/>
<circle cy="-50" r="8" fill="#fff"/>
</g>
</svg>
<div class="wdw-map-card wdw-card-sm p-3 d-flex align-items-center gap-3">
<span class="wdw-icon">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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>
</span>
<div class="flex-grow-1 min-w-0">
<p class="fw-bold mb-0 text-body-emphasis">Piazza del Colosseo, 1</p>
<p class="small wdw-muted mb-0">00184 Roma RM, Italy</p>
</div>
<a href="https://www.openstreetmap.org/search?query=Colosseo%20Roma" target="_blank" rel="noopener" class="btn btn-sm btn-outline-primary rounded-pill d-none d-sm-inline-flex">Directions</a>
</div>
</div>
<div class="col-lg-6 p-4 p-lg-5">
<span class="wdw-eyebrow">Contact</span>
<h2 class="wdw-heading h2 mt-1 mb-2">Let's talk about your project</h2>
<p class="wdw-muted mb-4">Send a message and we will reply within one working day.</p>
<form id="wdwContactForm" novalidate>
<div class="row g-3">
<div class="col-sm-6">
<div class="form-floating"><input type="text" class="form-control" id="cName" placeholder="Name" autocomplete="name" required><label for="cName">Name or company</label></div>
</div>
<div class="col-sm-6">
<div class="form-floating"><input type="text" class="form-control" id="cSubject" placeholder="Subject" required><label for="cSubject">Subject</label></div>
</div>
<div class="col-sm-6">
<div class="form-floating"><input type="email" class="form-control" id="cEmail" placeholder="Email" autocomplete="email" required><label for="cEmail">Email</label></div>
</div>
<div class="col-sm-6">
<div class="form-floating"><input type="tel" class="form-control" id="cPhone" placeholder="Phone" autocomplete="tel"><label for="cPhone">Phone (optional)</label></div>
</div>
<div class="col-12">
<div class="form-floating"><textarea class="form-control wdw-textarea" id="cMessage" placeholder="Message" required></textarea><label for="cMessage">How can we help?</label></div>
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="cTerms" required>
<label class="form-check-label small" for="cTerms">I agree to the privacy terms</label>
</div>
</div>
<div class="col-12 d-flex flex-wrap align-items-center gap-3">
<button type="submit" class="btn btn-primary rounded-pill px-4">Send message</button>
<span class="small text-success fw-semibold" id="wdwContactMsg" role="status" hidden>Thanks, your message is on its way.</span>
</div>
</div>
</form>
<hr class="my-4">
<ul class="list-unstyled row g-3 mb-0 small">
<li class="col-sm-6 d-flex align-items-center gap-2"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" class="text-primary flex-none" 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><a href="tel:+39123456" class="link-body-emphasis link-underline-opacity-0">(+39) 123 456</a></li>
<li class="col-sm-6 d-flex align-items-center gap-2"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" class="text-primary flex-none" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2.5"/><path d="m3 7 9 6 9-6"/></svg><a href="mailto:[email protected]" class="link-body-emphasis link-underline-opacity-0">[email protected]</a></li>
</ul>
</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 */
.wdw-map { min-height: 300px; --m-land: #e9ecf8; --m-road: #fff; --m-water: #c9dcf6; --m-park: #d4eedd; }
[data-bs-theme="dark"] .wdw-map { --m-land: #1a1d29; --m-road: #2b2f42; --m-water: #16253d; --m-park: #1b2d28; }
.wdw-map-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.m-land { fill: var(--m-land); }
.m-road path { stroke: var(--m-road); }
.m-water { fill: var(--m-water); }
.m-park { fill: var(--m-park); }
.m-halo { fill: rgba(79, 70, 229, .12); }
.m-halo2 { fill: rgba(79, 70, 229, .22); }
.m-pin-body { fill: #4f46e5; }
[data-bs-theme="dark"] .m-pin-body { fill: #818cf8; }
.wdw-map-card { position: absolute; left: 1rem; right: 1rem; bottom: 1rem; }
.min-w-0 { min-width: 0; }
.flex-none { flex: none; }
.wdw-textarea { min-height: 130px; height: 130px; }
.form-control.is-invalid { border-color: var(--bs-danger); }
@media (max-width: 991.98px) { .wdw-map { min-height: 280px; } }
.form-floating > textarea.wdw-textarea { height: 130px; min-height: 130px; }
function initContactForm() {
var form = document.getElementById('wdwContactForm');
if (!form) return;
var msg = document.getElementById('wdwContactMsg');
form.addEventListener('submit', function (e) {
e.preventDefault();
var valid = true;
form.querySelectorAll('[required]').forEach(function (field) {
var ok = field.checkValidity();
field.classList.toggle('is-invalid', !ok);
if (!ok) valid = false;
});
msg.hidden = !valid;
if (valid) form.reset();
});
form.addEventListener('input', function (e) { e.target.classList.remove('is-invalid'); msg.hidden = true; });
}
initContactForm();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.