Bootstrap 5 Animated Custom Checkboxes and Radio Buttons
Hand-drawn checkboxes and radio buttons with an animated tick and a springy selection dot, built on native inputs so keyboard and screen readers work.
<section class="wdw-stage">
<div class="container" style="max-width:1040px">
<div class="text-center mb-5">
<span class="wdw-eyebrow">Form controls</span>
<h1 class="wdw-heading display-6 mt-2 mb-2" style="text-wrap:balance">Animated checkboxes, radios and switches</h1>
<p class="wdw-muted mb-0 mx-auto" style="max-width:36rem">Selectable tiles with a drawn check, a springy radio dot and full keyboard support.</p>
</div>
<div class="row g-4">
<div class="col-lg-4 col-md-6">
<fieldset class="wdw-card p-4 h-100">
<legend class="h6 fw-bold mb-3 float-start w-100" id="g1">Notify me about</legend>
<label class="wdw-opt"><input type="checkbox"><span class="wdw-box" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7"/></svg></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a8 8 0 0 1-11.5 7.2L4 20l1-4.5A8 8 0 1 1 21 12z"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">New comments</span><span class="wdw-opt-help">Replies to your posts</span></span></label><label class="wdw-opt"><input type="checkbox" checked><span class="wdw-box" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7"/></svg></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2.5 2.5M15.5 15.5L18 18M18 6l-2.5 2.5M8.5 15.5L6 18"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Product updates</span><span class="wdw-opt-help">New features and fixes</span></span></label><label class="wdw-opt"><input type="checkbox"><span class="wdw-box" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7"/></svg></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Weekly digest</span><span class="wdw-opt-help">Every Monday morning</span></span></label>
</fieldset>
</div>
<div class="col-lg-4 col-md-6">
<fieldset class="wdw-card p-4 h-100">
<legend class="h6 fw-bold mb-3 float-start w-100" id="g2">Delivery speed</legend>
<label class="wdw-opt"><input type="radio" name="speed"><span class="wdw-radio" aria-hidden="true"></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7h11v9H3zM14 10h4l3 3v3h-7"/><circle cx="7" cy="18" r="1.5"/><circle cx="17" cy="18" r="1.5"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Standard</span><span class="wdw-opt-help">Arrives in 5 days</span></span></label><label class="wdw-opt"><input type="radio" name="speed" checked><span class="wdw-radio" aria-hidden="true"></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M13 3L5 14h6l-1 7 8-11h-6z"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Express</span><span class="wdw-opt-help">Arrives in 2 days</span></span></label><label class="wdw-opt"><input type="radio" name="speed"><span class="wdw-radio" aria-hidden="true"></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Same day</span><span class="wdw-opt-help">Order before 2 pm</span></span></label>
</fieldset>
</div>
<div class="col-lg-4 col-md-6">
<fieldset class="wdw-card p-4 h-100">
<legend class="h6 fw-bold mb-3 float-start w-100" id="g3">Preferences</legend>
<label class="wdw-opt"><span class="form-check form-switch m-0 p-0"><input class="form-check-input wdw-switch m-0" type="checkbox" role="switch" checked></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8M10 20a2 2 0 0 0 4 0"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Push alerts</span><span class="wdw-opt-help">On this device</span></span></label><label class="wdw-opt"><span class="form-check form-switch m-0 p-0"><input class="form-check-input wdw-switch m-0" type="checkbox" role="switch"></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="3"/><path d="M3 8l9 6 9-6"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Email receipts</span><span class="wdw-opt-help">After every order</span></span></label><label class="wdw-opt"><span class="form-check form-switch m-0 p-0"><input class="form-check-input wdw-switch m-0" type="checkbox" role="switch" checked></span><span class="wdw-icon wdw-opt-icon" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3l8 3v6c0 4.5-3.4 8-8 9-4.6-1-8-4.5-8-9V6z"/></svg></span><span class="wdw-opt-text"><span class="wdw-opt-title">Two-step login</span><span class="wdw-opt-help">Extra account security</span></span></label>
</fieldset>
</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-opt { display: flex; align-items: center; gap: .85rem; min-height: 64px; padding: .6rem .75rem; margin-bottom: .6rem; border: 1px solid var(--bs-border-color); border-radius: .875rem; cursor: pointer; position: relative; color: var(--bs-secondary-color); font-weight: 500; transition: color .2s, background .2s; }
.wdw-opt:hover { background: var(--bs-tertiary-bg); }
.wdw-opt input:not(.wdw-switch) { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.wdw-opt:has(input:checked) { color: var(--bs-emphasis-color); background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary); }
.wdw-opt:has(input:focus-visible) { box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
fieldset.wdw-card { min-width: 0; }
.wdw-opt-text { display: flex; flex-direction: column; line-height: 1.3; }
.wdw-opt-title { font-weight: 700; color: var(--bs-emphasis-color); }
.wdw-opt-help { font-size: .8125rem; color: var(--bs-secondary-color); }
.wdw-opt-icon { width: 2.25rem; height: 2.25rem; border-radius: .7rem; margin-left: auto; order: 3; }
.wdw-opt-text { order: 2; }
.wdw-opt .wdw-box, .wdw-opt .wdw-radio, .wdw-opt .form-switch { order: 1; }
.wdw-opt .wdw-switch { position: static; opacity: 1; width: 2.5em; height: 1.4em; inset: auto; border-color: var(--bs-secondary-color); cursor: pointer; }
.wdw-opt .form-switch { padding: 0; }
.wdw-opt .wdw-switch:checked { border-color: var(--bs-primary); }
.wdw-box, .wdw-radio { width: 1.5rem; height: 1.5rem; flex: none; border: 2px solid var(--bs-secondary-color); background: var(--bs-body-bg); transition: border-color .2s, background .2s, box-shadow .2s; display: inline-flex; align-items: center; justify-content: center; }
.wdw-box { border-radius: .45rem; }
.wdw-radio { border-radius: 50%; position: relative; }
.wdw-box svg { width: 1rem; height: 1rem; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .3s ease; }
[data-bs-theme="dark"] .wdw-box svg { stroke: #0f1117; }
.wdw-opt input:checked + .wdw-box { background: var(--bs-primary); border-color: var(--bs-primary); }
.wdw-opt input:checked + .wdw-box svg { stroke-dashoffset: 0; }
.wdw-radio::after { content: ""; width: .7rem; height: .7rem; border-radius: 50%; background: var(--bs-primary); transform: scale(0); transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
.wdw-opt input:checked + .wdw-radio { border-color: var(--bs-primary); }
.wdw-opt input:checked + .wdw-radio::after { transform: scale(1); }
.wdw-opt input:focus-visible + .wdw-box, .wdw-opt input:focus-visible + .wdw-radio { box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
@media (prefers-reduced-motion: reduce) { .wdw-box svg, .wdw-radio::after { transition: none; } }
/* Custom box/radio instead of .form-check-input: needed for the drawn-check and spring-dot animations. */
legend + .wdw-opt { clear: both; }
<section class="ac-stage">
<form class="ac-card" id="prefsForm">
<header class="ac-head">
<h1 class="fs-2xl fw-bold mb-2">Notification preferences</h1>
<p class="fg-secondary mb-0">Choose what we email you about and how you would like to be billed.</p>
</header>
<div class="ac-grid">
<fieldset class="ac-group">
<legend class="ac-legend">Notify me about</legend>
<div class="ac-item"><input class="check" id="n1" type="checkbox">
<label class="ac-label" for="n1"><span class="ac-title">Product updates</span><span class="ac-desc">New features, once a month.</span></label></div>
<div class="ac-item"><input class="check" id="n2" type="checkbox" checked>
<label class="ac-label" for="n2"><span class="ac-title">Security alerts</span><span class="ac-desc">Sign-ins from new devices.</span></label></div>
<div class="ac-item"><input class="check" id="n3" type="checkbox">
<label class="ac-label" for="n3"><span class="ac-title">Billing receipts</span><span class="ac-desc">A copy of every invoice.</span></label></div>
</fieldset>
<fieldset class="ac-group">
<legend class="ac-legend">Billing cycle</legend>
<div class="ac-item"><input class="radio" id="r1" type="radio" name="billing">
<label class="ac-label" for="r1"><span class="ac-title">Monthly</span><span class="ac-desc">Pay month to month, cancel any time.</span></label></div>
<div class="ac-item"><input class="radio" id="r2" type="radio" name="billing" checked>
<label class="ac-label" for="r2"><span class="ac-title">Yearly</span><span class="ac-desc">Two months free, billed once a year.</span></label></div>
<div class="ac-item"><input class="radio" id="r3" type="radio" name="billing">
<label class="ac-label" for="r3"><span class="ac-title">Every two years</span><span class="ac-desc">Best price, billed every 24 months.</span></label></div>
</fieldset>
</div>
<div class="ac-foot"><button type="button" class="btn-subtle theme-secondary">Cancel</button><button type="submit" class="btn-solid theme-primary">Save preferences</button></div>
</form>
</section>
.ac-stage { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--bs-bg-2); }
.ac-card { width: 100%; max-width: 46rem; background: var(--bs-bg-body); border: 1px solid var(--bs-border-color); border-radius: 1.25rem; padding: 2rem; box-shadow: 0 20px 50px -28px rgb(0 0 0 / .3); }
.ac-head { margin-bottom: 1.75rem; }
.ac-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.ac-group { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: .5rem; }
.ac-legend { float: none; width: auto; padding: 0; margin-bottom: .75rem; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-fg-3); }
/* v6 .check / .radio sit on top of a full-width label card */
.ac-item { position: relative; border: 1px solid var(--bs-border-color); border-radius: .875rem; transition: border-color .2s, background-color .2s; }
.ac-item:hover { background: var(--bs-bg-1); }
.ac-item .check, .ac-item .radio { position: absolute; top: 1rem; left: 1rem; margin: 0; }
.ac-label { display: flex; flex-direction: column; gap: .125rem; padding: .875rem 1rem .875rem 3.0rem; cursor: pointer; }
.ac-title { font-weight: 600; color: var(--bs-fg-body); }
.ac-desc { font-size: .8125rem; color: var(--bs-fg-3); }
.ac-item:has(:checked) { border-color: var(--bs-primary-base); background: color-mix(in oklch, var(--bs-primary-base) 7%, transparent); }
.ac-item:has(:focus-visible) { outline: 2px solid var(--bs-primary-base); outline-offset: 2px; }
.ac-item .check:focus-visible, .ac-item .radio:focus-visible { outline: none; }
.ac-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--bs-border-color); }
@media (prefers-reduced-motion: reduce) { .ac-item { transition: none; } }
@media (width < 640px) { .ac-grid { grid-template-columns: 1fr; gap: 1.5rem; } .ac-card { padding: 1.5rem 1.25rem; } }
function initPrefsForm() {
const form = document.getElementById('prefsForm');
if (!form) return;
form.addEventListener('submit', (e) => e.preventDefault());
}
initPrefsForm();
Built on Bootstrap 6.0.0-alpha.1 (ES modules, no jQuery). Load Bootstrap through an import map and run the JavaScript as type="module" — the downloaded file is already set up that way. Alpha releases can still change class names.
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.