Bootstrap 5 Sliding Sign In / Sign Up Form
A sign-in and sign-up card where a gradient panel slides across to switch between the two forms, collapsing to a simple text-link toggle on small screens.
<section class="wdw-stage">
<div class="container sw-wrap">
<div class="sw card wdw-card overflow-hidden" id="sw" data-mode="signin">
<!-- Sign in -->
<div class="sw-pane sw-pane-in p-4 p-md-5" id="sw-in">
<div class="sw-seg d-md-none nav nav-pills sw-track rounded-pill p-1 mb-4" role="group" aria-label="Choose form">
<button type="button" class="nav-link rounded-pill flex-fill active" data-sw-go="signin" aria-pressed="true">Sign in</button>
<button type="button" class="nav-link rounded-pill flex-fill " data-sw-go="signup" aria-pressed="false">Sign up</button>
</div>
<form class="sw-form" novalidate>
<h1 class="h3 wdw-heading mb-1">Welcome back</h1>
<p class="text-body-secondary mb-4">Sign in to continue to your dashboard.</p>
<div class="row g-2 mb-3"><div class="col-6"><button type="button" class="btn btn-outline-secondary text-body rounded-pill w-100 d-flex align-items-center justify-content-center gap-2"><svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true"><path fill="#4285F4" d="M23 12.3c0-.8-.1-1.500-.2-2.200H12v4.200h6.200a5.300 5.300 0 0 1-2.300 3.500v2.900h3.700c2.200-2 3.400-5 3.400-8.400z"/><path fill="#34A853" d="M12 24c3.100 0 5.700-1 7.600-2.800l-3.700-2.900c-1 .7-2.300 1.100-3.900 1.100-3 0-5.500-2-6.400-4.700H1.800v3A12 12 0 0 0 12 24z"/><path fill="#FBBC05" d="M5.600 14.700a7.200 7.200 0 0 1 0-4.600v-3H1.800a12 12 0 0 0 0 10.600z"/><path fill="#EA4335" d="M12 4.800c1.700 0 3.200.6 4.400 1.700l3.300-3.300A12 12 0 0 0 1.800 7.100l3.800 3C6.500 6.800 9 4.800 12 4.800z"/></svg>Google</button></div><div class="col-6"><button type="button" class="btn btn-outline-secondary text-body rounded-pill w-100 d-flex align-items-center justify-content-center gap-2"><svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 .5a11.500 11.500 0 0 0-3.600 22.400c.6.100.8-.2.8-.6v-2c-3.200.7-3.900-1.500-3.900-1.500-.5-1.300-1.300-1.700-1.300-1.700-1-.7.1-.7.1-.7 1.200.1 1.800 1.200 1.800 1.200 1 1.800 2.700 1.300 3.400 1 .1-.8.4-1.300.7-1.600-2.600-.3-5.300-1.300-5.300-5.700 0-1.300.5-2.300 1.200-3.100-.1-.3-.5-1.500.1-3.100 0 0 1-.3 3.200 1.200a11 11 0 0 1 5.800 0c2.200-1.500 3.200-1.200 3.200-1.200.6 1.600.2 2.800.1 3.100.8.800 1.200 1.800 1.200 3.100 0 4.400-2.700 5.400-5.300 5.700.4.400.8 1.100.8 2.200v3.200c0 .4.200.7.800.6A11.500 11.500 0 0 0 12 .5z"/></svg>GitHub</button></div></div><div class="d-flex align-items-center gap-3 text-body-secondary small mb-3"><hr class="flex-grow-1 m-0"><span>or with email</span><hr class="flex-grow-1 m-0"></div>
<div class="sw-field position-relative mb-3"><svg class="sw-ico" 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"><rect x="3" y="5" width="18" height="14" rx="3"/><path d="M3 8l9 6 9-6"/></svg><div class="form-floating"><input type="email" class="form-control" id="sw-in-email" placeholder="Email" autocomplete="email" required><label for="sw-in-email">Email</label></div></div>
<div class="sw-field position-relative mb-1"><svg class="sw-ico" 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"><rect x="4" y="10" width="16" height="11" rx="3"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/></svg><div class="form-floating"><input type="password" class="form-control" id="sw-in-pass" placeholder="Password" autocomplete="current-password" required><label for="sw-in-pass">Password</label></div><button type="button" class="sw-eye" data-sw-eye aria-label="Show password" aria-pressed="false"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.500-7 10-7 10 7 10 7-3.500 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg></button></div>
<div class="d-flex justify-content-between align-items-center mb-3"><div class="form-check mb-0"><input class="form-check-input" type="checkbox" id="sw-keep"><label class="form-check-label small" for="sw-keep">Keep me signed in</label></div><a href="#" class="sw-forgot">Forgot password?</a></div>
<button type="submit" class="btn btn-primary w-100 rounded-pill">Sign in</button>
</form>
</div>
<!-- Sign up -->
<div class="sw-pane sw-pane-up p-4 p-md-5" id="sw-up">
<div class="sw-seg d-md-none nav nav-pills sw-track rounded-pill p-1 mb-4" role="group" aria-label="Choose form">
<button type="button" class="nav-link rounded-pill flex-fill " data-sw-go="signin" aria-pressed="false">Sign in</button>
<button type="button" class="nav-link rounded-pill flex-fill active" data-sw-go="signup" aria-pressed="true">Sign up</button>
</div>
<form class="sw-form" novalidate>
<h1 class="h3 wdw-heading mb-1">Create account</h1>
<p class="text-body-secondary mb-4">It takes less than a minute.</p>
<div class="row g-2 mb-3"><div class="col-6"><button type="button" class="btn btn-outline-secondary text-body rounded-pill w-100 d-flex align-items-center justify-content-center gap-2"><svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true"><path fill="#4285F4" d="M23 12.3c0-.8-.1-1.500-.2-2.200H12v4.200h6.200a5.300 5.300 0 0 1-2.300 3.500v2.900h3.700c2.200-2 3.400-5 3.400-8.400z"/><path fill="#34A853" d="M12 24c3.100 0 5.700-1 7.600-2.800l-3.700-2.900c-1 .7-2.300 1.100-3.900 1.100-3 0-5.500-2-6.400-4.700H1.800v3A12 12 0 0 0 12 24z"/><path fill="#FBBC05" d="M5.600 14.700a7.200 7.200 0 0 1 0-4.600v-3H1.800a12 12 0 0 0 0 10.600z"/><path fill="#EA4335" d="M12 4.800c1.700 0 3.200.6 4.400 1.700l3.300-3.300A12 12 0 0 0 1.800 7.100l3.800 3C6.500 6.800 9 4.800 12 4.800z"/></svg>Google</button></div><div class="col-6"><button type="button" class="btn btn-outline-secondary text-body rounded-pill w-100 d-flex align-items-center justify-content-center gap-2"><svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 .5a11.500 11.500 0 0 0-3.600 22.400c.6.100.8-.2.8-.6v-2c-3.200.7-3.900-1.500-3.900-1.500-.5-1.300-1.300-1.700-1.300-1.700-1-.7.1-.7.1-.7 1.200.1 1.800 1.200 1.800 1.200 1 1.800 2.700 1.300 3.400 1 .1-.8.4-1.300.7-1.600-2.600-.3-5.300-1.300-5.300-5.700 0-1.300.5-2.300 1.200-3.100-.1-.3-.5-1.500.1-3.100 0 0 1-.3 3.200 1.200a11 11 0 0 1 5.800 0c2.200-1.500 3.200-1.200 3.200-1.200.6 1.600.2 2.800.1 3.100.8.800 1.200 1.800 1.200 3.100 0 4.400-2.700 5.400-5.300 5.700.4.400.8 1.100.8 2.200v3.200c0 .4.200.7.800.6A11.500 11.500 0 0 0 12 .5z"/></svg>GitHub</button></div></div><div class="d-flex align-items-center gap-3 text-body-secondary small mb-3"><hr class="flex-grow-1 m-0"><span>or with email</span><hr class="flex-grow-1 m-0"></div>
<div class="sw-field position-relative mb-3"><svg class="sw-ico" 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"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg><div class="form-floating"><input type="text" class="form-control" id="sw-up-name" placeholder="Full name" autocomplete="name" required><label for="sw-up-name">Full name</label></div></div>
<div class="sw-field position-relative mb-3"><svg class="sw-ico" 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"><rect x="3" y="5" width="18" height="14" rx="3"/><path d="M3 8l9 6 9-6"/></svg><div class="form-floating"><input type="email" class="form-control" id="sw-up-email" placeholder="Email" autocomplete="email" required><label for="sw-up-email">Email</label></div></div>
<div class="sw-field position-relative mb-4"><svg class="sw-ico" 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"><rect x="4" y="10" width="16" height="11" rx="3"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/></svg><div class="form-floating"><input type="password" class="form-control" id="sw-up-pass" placeholder="Password" autocomplete="new-password" required><label for="sw-up-pass">Password</label></div><button type="button" class="sw-eye" data-sw-eye aria-label="Show password" aria-pressed="false"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.500-7 10-7 10 7 10 7-3.500 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg></button></div>
<button type="submit" class="btn btn-primary w-100 rounded-pill">Sign up</button>
</form>
</div>
<!-- Sliding brand panel (desktop) -->
<div class="sw-overlay wdw-aurora d-none d-md-flex text-white">
<div class="sw-ov sw-ov-to-up">
<div class="d-flex align-items-center gap-2 fw-semibold mb-4"><span class="sw-logo" aria-hidden="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M4 18 10 6l4 8 2-4 4 8"/></svg></span>Harbor</div>
<h2 class="h2 fw-bold mb-3">Plan, track and ship together.</h2>
<div class="sw-mock mb-4" aria-hidden="true"><div class="d-flex justify-content-between small mb-2"><span>Weekly activity</span><span class="fw-semibold">+24%</span></div><div class="sw-bars"><i style="height:38%"></i><i style="height:55%"></i><i style="height:42%"></i><i style="height:70%"></i><i style="height:60%"></i><i style="height:88%"></i><i style="height:76%"></i></div></div>
<p class="small opacity-75 mb-2">New here?</p>
<button type="button" class="btn btn-light rounded-pill px-4 align-self-start" data-sw-go="signup">Create an account</button>
</div>
<div class="sw-ov sw-ov-to-in">
<div class="d-flex align-items-center gap-2 fw-semibold mb-4"><span class="sw-logo" aria-hidden="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M4 18 10 6l4 8 2-4 4 8"/></svg></span>Harbor</div>
<h2 class="h2 fw-bold mb-3">Your workspace is waiting.</h2>
<div class="sw-mock mb-4" aria-hidden="true"><div class="small mb-1 opacity-75">Open tasks</div><div class="sw-big">18 <span class="small fw-normal opacity-75">due this week</span></div><div class="progress sw-mp mt-2"><div class="progress-bar bg-white" style="width:64%"></div></div></div>
<p class="small opacity-75 mb-2">Already a member?</p>
<button type="button" class="btn btn-light rounded-pill px-4 align-self-start" data-sw-go="signin">Sign in</button>
</div>
</div>
<p class="visually-hidden" role="status" id="sw-status">Sign in form shown</p>
</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 */
.sw-wrap{max-width:960px}
.sw-form a,.sw-form .btn-link{text-decoration:none}
.sw-form a:hover,.sw-form .btn-link:hover{text-decoration:underline}
.sw-pane{display:none}
.sw[data-mode="signin"] .sw-pane-in,.sw[data-mode="signup"] .sw-pane-up{display:block}
@media (min-width:768px){
.sw{display:grid;grid-template-columns:1fr 1fr;min-height:560px;position:relative}
.sw-pane{display:flex!important;flex-direction:column;justify-content:center;padding:3rem!important}
.sw-pane-in{grid-column:1}.sw-pane-up{grid-column:2}
.sw-pane-in,.sw-pane-up{grid-row:1}
.sw-overlay{position:absolute;top:0;left:50%;width:50%;height:100%;z-index:2;
transition:transform .6s cubic-bezier(.65,0,.35,1);align-items:center;justify-content:center;overflow:hidden}
.sw-overlay::after{content:"";position:absolute;inset:0;pointer-events:none;opacity:.18;mix-blend-mode:overlay;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")}
.sw[data-mode="signup"] .sw-overlay{transform:translateX(-100%)}
.sw-ov{position:absolute;inset:0;display:flex;flex-direction:column;align-items:flex-start;justify-content:center;padding:2.75rem;z-index:1;transition:opacity .4s ease,transform .6s cubic-bezier(.65,0,.35,1)}
.sw[data-mode="signin"] .sw-ov-to-in{opacity:0;visibility:hidden;transform:translateX(30%)}
.sw[data-mode="signup"] .sw-ov-to-up{opacity:0;visibility:hidden;transform:translateX(-30%)}
.sw[data-mode="signin"] .sw-pane-up,.sw[data-mode="signup"] .sw-pane-in{visibility:hidden}
}
@media (prefers-reduced-motion:reduce){.sw-overlay,.sw-ov{transition:none}}
.sw-logo{width:28px;height:28px;border-radius:9px;background:#fff;color:#4f46e5;display:inline-flex;align-items:center;justify-content:center}
.sw-perks li{position:relative;padding-left:1.75rem;margin-bottom:.6rem;opacity:.92}
.sw-perks li::before{content:"";position:absolute;left:0;top:.2em;width:1.1rem;height:1.1rem;border-radius:50%;background:rgba(255,255,255,.22) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2' d='M4 8.5l2.500 2.500L12 5.500'/%3E%3C/svg%3E") center/80% no-repeat}
.sw-forgot{font-size:.875rem;font-weight:600;display:inline-block;padding:.5rem 0}
.sw-track{background:var(--bs-secondary-bg);border:1px solid var(--bs-border-color)}
.sw-mock{width:100%;background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.2);border-radius:1rem;padding:1rem 1.1rem}
.sw-bars{display:flex;align-items:flex-end;gap:.4rem;height:84px}
.sw-bars i{flex:1;background:rgba(255,255,255,.75);border-radius:.4rem .4rem .15rem .15rem}
.sw-bars i:nth-child(6){background:#fff}
.sw-big{font-size:2.25rem;font-weight:800;letter-spacing:-.02em;line-height:1.1}
.sw-mp{height:8px;background:rgba(255,255,255,.25)}
.sw-ico{position:absolute;left:1rem;top:50%;transform:translateY(-50%);color:var(--bs-secondary-color);z-index:4;pointer-events:none}
.sw-field .form-control{padding-left:2.9rem}
.sw-field .form-floating>label{padding-left:2.9rem}
.sw-field .form-floating>.form-control:focus~label,.sw-field .form-floating>.form-control:not(:placeholder-shown)~label{padding-left:2.9rem}
.sw-eye{position:absolute;top:50%;right:.35rem;transform:translateY(-50%);width:44px;height:44px;display:inline-flex;align-items:center;justify-content:center;border:0;background:transparent;color:var(--bs-secondary-color);border-radius:50%;z-index:5}
.sw-eye:hover{color:var(--bs-emphasis-color)}
.sw-eye:focus-visible{outline:2px solid var(--bs-primary);outline-offset:-2px}
.sw-field .sw-eye~*{}
.sw-seg .nav-link{color:var(--bs-secondary-color);font-weight:600}
.sw-seg .nav-link.active{color:#fff}
.sw-pane[inert]{visibility:hidden}
function initAuthSwitch() {
const root = document.getElementById('sw');
if (!root) return;
const status = document.getElementById('sw-status');
const panes = { signin: document.getElementById('sw-in'), signup: document.getElementById('sw-up') };
const wide = window.matchMedia('(min-width: 768px)');
const setMode = (mode, focus) => {
root.dataset.mode = mode;
Object.entries(panes).forEach(([key, pane]) => {
const off = key !== mode;
pane.inert = off;
pane.setAttribute('aria-hidden', off ? 'true' : 'false');
});
root.querySelectorAll('.sw-seg [data-sw-go]').forEach((b) => {
const on = b.dataset.swGo === mode;
b.classList.toggle('active', on);
b.setAttribute('aria-pressed', on);
});
if (status) status.textContent = (mode === 'signin' ? 'Sign in' : 'Sign up') + ' form shown';
if (!focus) return;
const first = panes[mode].querySelector('input');
if (first) setTimeout(() => first.focus({ preventScroll: true }), wide.matches ? 450 : 0);
};
root.querySelectorAll('[data-sw-go]').forEach((btn) => {
btn.addEventListener('click', () => setMode(btn.dataset.swGo, true));
});
root.querySelectorAll('form').forEach((form) => {
form.addEventListener('submit', (e) => {
e.preventDefault();
form.classList.add('was-validated');
});
});
setMode('signin', false);
}
function initPasswordEyes() {
document.querySelectorAll('[data-sw-eye]').forEach((btn) => {
const input = btn.parentElement.querySelector('input');
if (!input) return;
btn.addEventListener('click', () => {
const show = input.type === 'password';
input.type = show ? 'text' : 'password';
btn.setAttribute('aria-pressed', show);
btn.setAttribute('aria-label', show ? 'Hide password' : 'Show password');
});
});
}
initAuthSwitch();
initPasswordEyes();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.