02Doubling backoff wait — the time value left before the next try doubles with each failure
As the failure count rises, the wait-time value grows to twice its previous value each time.
Best forA security-critical admin login screen, a finance app authentication screen
BACKOFF_BASE_SECCAP_SECDEMO_TICK_MS

<main class="stage">
<div class="abt is-demo" id="abt">
<div class="abt__card">
<div class="abt__row">
<span class="abt__label">Fail <b id="abtFails">0</b>times</span>
<span class="abt__wait" id="abtWait">No wait</span>
</div>
<div class="abt__track"><div class="abt__fill" id="abtFill"></div></div>
<button class="abt__btn" id="abtBtn" type="button">Login attempt</button>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// 계산 겹: 대기초 = min(CAP, BACKOFF_BASE×2^실패횟수) — index.html 참조. 막대는 남은비율로 scaleX
@include stage($stage-orange);
.abt {
width: 100%;
max-width: 300px;
}
.abt__card {
display: grid;
gap: $sp-3;
}
.abt__row {
display: flex;
align-items: baseline;
justify-content: space-between;
font: 600 13px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: $subject-cream;
}
.abt__label b { font-size: 16px; font-variant-numeric: tabular-nums; }
.abt__wait {
font-variant-numeric: tabular-nums;
color: $subject-cream;
}
.abt__track {
position: relative;
height: $sp-3;
border-radius: $r-sm;
background: rgba(23, 20, 26, .28);
overflow: hidden;
}
.abt__fill {
position: absolute;
inset: 0;
border-radius: $r-sm;
background: $stage-ink;
transform: scaleX(0);
transform-origin: right center;
}
.abt__btn {
border: 0;
border-radius: $r-control;
padding: $sp-2 $sp-4;
background: $stage-ink;
color: $subject-cream;
font: 700 14px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
cursor: pointer;
transition: opacity $dur-instant $ease-out;
&:disabled { opacity: .5; cursor: not-allowed; }
}
@media (max-width: 340px) {
.abt { max-width: 220px; }
.abt__row { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
.abt__btn { transition: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ff4d1f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.abt {
width: 100%;
max-width: 300px;
}
.abt__card {
display: grid;
gap: 12px;
}
.abt__row {
display: flex;
align-items: baseline;
justify-content: space-between;
font: 600 13px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: #fff7e6;
}
.abt__label b {
font-size: 16px;
font-variant-numeric: tabular-nums;
}
.abt__wait {
font-variant-numeric: tabular-nums;
color: #fff7e6;
}
.abt__track {
position: relative;
height: 12px;
border-radius: 8px;
background: rgba(23, 20, 26, 0.28);
overflow: hidden;
}
.abt__fill {
position: absolute;
inset: 0;
border-radius: 8px;
background: #17141a;
transform: scaleX(0);
transform-origin: right center;
}
.abt__btn {
border: 0;
border-radius: 12px;
padding: 8px 16px;
background: #17141a;
color: #fff7e6;
font: 700 14px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
cursor: pointer;
transition: opacity 140ms ease-out;
}
.abt__btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
@media (max-width: 340px) {
.abt {
max-width: 220px;
}
.abt__row {
font-size: 12px;
}
}
@media (prefers-reduced-motion: reduce) {
.abt__btn {
transition: none;
}
}(function () {
var root = document.getElementById('abt');
var btn = document.getElementById('abtBtn');
var failsEl = document.getElementById('abtFails');
var waitEl = document.getElementById('abtWait');
var fill = document.getElementById('abtFill');
// 상수: 지수 백오프 = BACKOFF_BASE_SEC × 2^실패횟수(sec), CAP_SEC 에서 증가를 멈춘다
var BACKOFF_BASE_SEC = 1;
var CAP_SEC = 16;
var DEMO_TICK_MS = 90; // 데모 안에서 "1sec"를 표현하는 실제 ms(가속)
var fails = 0;
var locked = false;
var rafId = null;
function waitSecondsOf(n) {
return Math.min(CAP_SEC, BACKOFF_BASE_SEC * Math.pow(2, n));
}
function countdown(totalSec) {
locked = true;
btn.disabled = true;
var start = null;
var totalMs = totalSec * DEMO_TICK_MS;
function frame(ts) {
if (start === null) start = ts;
var elapsed = ts - start;
var left = Math.max(0, totalSec - elapsed / DEMO_TICK_MS);
waitEl.textContent = 'Until next try ' + Math.ceil(left) + 'sec';
fill.style.transform = 'scaleX(' + Math.max(0, left / totalSec) + ')';
if (elapsed < totalMs) { rafId = requestAnimationFrame(frame); }
else {
waitEl.textContent = 'No wait';
fill.style.transform = 'scaleX(0)';
locked = false;
btn.disabled = false;
}
}
rafId = requestAnimationFrame(frame);
}
function fail() {
if (locked) return;
fails += 1;
failsEl.textContent = String(fails);
countdown(waitSecondsOf(fails));
}
function reset() {
if (rafId) cancelAnimationFrame(rafId);
fails = 0;
locked = false;
btn.disabled = false;
failsEl.textContent = '0';
waitEl.textContent = 'No wait';
fill.style.transform = 'scaleX(0)';
}
btn.addEventListener('click', function () {
root.classList.remove('is-demo');
stopAutoplay();
fail();
});
var autoTimer = null;
var stage = 0;
function autoTick() {
if (locked) return;
if (stage >= 4) { reset(); stage = 0; return; }
fail();
stage += 1;
}
function stopAutoplay() { if (autoTimer) { clearInterval(autoTimer); autoTimer = null; } }
var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!reduce) { autoTimer = setInterval(autoTick, 260); }
})();import { useEffect, useRef } from "react";
import styles from "./AuthAttemptBackoffTimer.module.scss";
type Box<T> = { current: T };
export default function AuthAttemptBackoffTimer() {
const rootRef = useRef(null) as unknown as Box<HTMLDivElement | null>;
useEffect(() => {
const root = rootRef.current;
if (!root) return;
const btn = root.querySelector(`.${styles.btn}`) as HTMLButtonElement | null;
const failsEl = root.querySelector(`.${styles.fails}`) as HTMLElement | null;
const waitEl = root.querySelector(`.${styles.wait}`) as HTMLElement | null;
const fill = root.querySelector(`.${styles.fill}`) as HTMLElement | null;
if (!btn || !failsEl || !waitEl || !fill) return;
// 상수: 지수 백오프 = BACKOFF_BASE_SEC × 2^실패횟수(초), CAP_SEC 에서 증가를 멈춘다
const BACKOFF_BASE_SEC = 1;
const CAP_SEC = 16;
const DEMO_TICK_MS = 90;
let fails = 0;
let locked = false;
let rafId: number | null = null;
function waitSecondsOf(n: number) {
return Math.min(CAP_SEC, BACKOFF_BASE_SEC * Math.pow(2, n));
}
function countdown(totalSec: number) {
locked = true;
btn!.disabled = true;
let start: number | null = null;
const totalMs = totalSec * DEMO_TICK_MS;
function frame(ts: number) {
if (start === null) start = ts;
const elapsed = ts - start;
const left = Math.max(0, totalSec - elapsed / DEMO_TICK_MS);
waitEl!.textContent = "다음 시도까지 " + Math.ceil(left) + "초";
fill!.style.transform = "scaleX(" + Math.max(0, left / totalSec) + ")";
if (elapsed < totalMs) { rafId = requestAnimationFrame(frame); }
else {
waitEl!.textContent = "대기 없음";
fill!.style.transform = "scaleX(0)";
locked = false;
btn!.disabled = false;
}
}
rafId = requestAnimationFrame(frame);
}
function fail() {
if (locked) return;
fails += 1;
failsEl!.textContent = String(fails);
countdown(waitSecondsOf(fails));
}
function reset() {
if (rafId !== null) cancelAnimationFrame(rafId);
fails = 0;
locked = false;
btn!.disabled = false;
failsEl!.textContent = "0";
waitEl!.textContent = "대기 없음";
fill!.style.transform = "scaleX(0)";
}
function onClick() {
root!.classList.remove(styles["is-demo"]);
stopAutoplay();
fail();
}
btn.addEventListener("click", onClick);
let autoTimer: number | null = null;
let stage = 0;
function autoTick() {
if (locked) return;
if (stage >= 4) { reset(); stage = 0; return; }
fail();
stage += 1;
}
function stopAutoplay() { if (autoTimer !== null) { window.clearInterval(autoTimer); autoTimer = null; } }
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (!reduce) { autoTimer = window.setInterval(autoTick, 260); }
return () => {
stopAutoplay();
if (rafId !== null) cancelAnimationFrame(rafId);
btn.removeEventListener("click", onClick);
};
}, []);
return (
<div ref={rootRef} className={`${styles.stage} ${styles.abt} ${styles["is-demo"]}`}>
<div className={styles.card}>
<div className={styles.row}>
<span className={styles.label}>실패 <b className={styles.fails}>0</b>회</span>
<span className={styles.wait}>대기 없음</span>
</div>
<div className={styles.track}><div className={styles.fill} /></div>
<button className={styles.btn} type="button">로그인 시도</button>
</div>
</div>
);
}02 Doubling backoff wait — the time value left before the next try doubles with each failure — Measured area 9.492% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · Too Many Failed Login Attempts: 9 Patterns
The post this demo lives in
Too Many Failed Login Attempts: 9 PatternsOne value drops by one per failed try, another doubles the wait time as failures pile up, and another counts a remaining See all demos in this post
If you like this effect - similar demos
Auth UI01 Scan-line sweep — a scan-progress value moves top to bottom while the ridge-brightness value at each passed line rises in orderFingerprint Scan Animation: 9 Biometric UI Demos
Auth UI01 A Glyph Board Where Each Pixel Column Slides Along a Sine Wave and the Letters BendCSS Captcha: 9 Warped Text and Rotate Checks
Auth UI01 Glassmorphic login card9 Login Form Design Patterns You Can Copy-Paste