03Lockout progress ring — the remaining-tries value is shown as a circular progress value
As the remaining-tries value falls, the circular progress value shrinks along with it.
Best forA mobile app login screen, a device unlock screen
MAX_TRIESRCIRC

<main class="stage">
<div class="alr is-demo" id="alr">
<div class="alr__ringwrap">
<svg class="alr__ring" viewBox="0 0 100 100" width="120" height="120">
<circle class="alr__track" cx="50" cy="50" r="40"></circle>
<circle class="alr__prog" id="alrProg" cx="50" cy="50" r="40"></circle>
</svg>
<div class="alr__mid">
<span class="alr__count" id="alrCount">5</span>
<span class="alr__label">Tries left</span>
</div>
</div>
<button class="alr__btn" id="alrBtn" type="button">Login attempt</button>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// 계산 겹: stroke-dashoffset = 둘레×(1 − 남은시도/최대시도) — index.html 참조
@include stage($stage-paper);
.alr {
display: grid;
justify-items: center;
gap: $sp-4;
}
.alr__ringwrap {
position: relative;
display: grid;
place-items: center;
}
.alr__ring {
transform: rotate(-90deg);
}
.alr__track {
fill: none;
stroke: rgba($stage-ink, .12);
stroke-width: 8;
}
.alr__prog {
fill: none;
stroke: $subject-blue-deep;
stroke-width: 8;
stroke-linecap: round;
transition: stroke-dashoffset $dur-base $ease-out, stroke $dur-base $ease-out;
}
.alr--locked .alr__prog { stroke: $error; }
.alr__mid {
position: absolute;
display: grid;
justify-items: center;
}
.alr__count {
font: 800 30px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: $stage-ink;
font-variant-numeric: tabular-nums;
}
.alr__label {
font: 500 11px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: rgba($stage-ink, .6);
}
.alr__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: transform $dur-instant $ease-out;
&:active { transform: scale(.96); }
}
@media (max-width: 340px) {
.alr__ring { width: 92px; height: 92px; }
.alr__count { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
.alr__prog { transition: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffffff;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.alr {
display: grid;
justify-items: center;
gap: 16px;
}
.alr__ringwrap {
position: relative;
display: grid;
place-items: center;
}
.alr__ring {
transform: rotate(-90deg);
}
.alr__track {
fill: none;
stroke: rgba(23, 20, 26, 0.12);
stroke-width: 8;
}
.alr__prog {
fill: none;
stroke: #0a4fe8;
stroke-width: 8;
stroke-linecap: round;
transition: stroke-dashoffset 300ms ease-out, stroke 300ms ease-out;
}
.alr--locked .alr__prog {
stroke: #c2361a;
}
.alr__mid {
position: absolute;
display: grid;
justify-items: center;
}
.alr__count {
font: 800 30px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: #17141a;
font-variant-numeric: tabular-nums;
}
.alr__label {
font: 500 11px/1 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: rgba(23, 20, 26, 0.6);
}
.alr__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: transform 140ms ease-out;
}
.alr__btn:active {
transform: scale(0.96);
}
@media (max-width: 340px) {
.alr__ring {
width: 92px;
height: 92px;
}
.alr__count {
font-size: 24px;
}
}
@media (prefers-reduced-motion: reduce) {
.alr__prog {
transition: none;
}
}(function () {
var root = document.getElementById('alr');
var btn = document.getElementById('alrBtn');
var countEl = document.getElementById('alrCount');
var prog = document.getElementById('alrProg');
// 상수: 최대 시도 횟수·링 반지름(SVG viewBox 좌표)
var MAX_TRIES = 5;
var R = 40;
var CIRC = 2 * Math.PI * R; // 원둘레
prog.style.strokeDasharray = CIRC.toFixed(2);
var remaining = MAX_TRIES;
// 계산 겹: 링 오프셋 = 둘레 × (1 − 남은/최대) — stroke-dashoffset 산술
function paint() {
countEl.textContent = String(remaining);
var offset = CIRC * (1 - remaining / MAX_TRIES);
prog.style.strokeDashoffset = offset.toFixed(2);
root.classList.toggle('alr--locked', remaining <= 0);
}
function fail() {
if (remaining <= 0) { remaining = MAX_TRIES; paint(); return; }
remaining -= 1;
paint();
}
btn.addEventListener('click', function () {
root.classList.remove('is-demo');
stopAutoplay();
fail();
});
paint();
var autoTimer = null;
function stopAutoplay() { if (autoTimer) { clearInterval(autoTimer); autoTimer = null; } }
var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!reduce) { autoTimer = setInterval(fail, 380); }
})();import { useEffect, useRef } from "react";
import styles from "./AuthAttemptLockoutRing.module.scss";
type Box<T> = { current: T };
export default function AuthAttemptLockoutRing() {
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 countEl = root.querySelector(`.${styles.count}`) as HTMLElement | null;
const prog = root.querySelector(`.${styles.prog}`) as SVGCircleElement | null;
if (!btn || !countEl || !prog) return;
// 상수: 최대 시도 횟수·링 반지름(SVG viewBox 좌표)
const MAX_TRIES = 5;
const R = 40;
const CIRC = 2 * Math.PI * R;
prog.style.strokeDasharray = CIRC.toFixed(2);
let remaining = MAX_TRIES;
// 계산 겹: 링 오프셋 = 둘레 × (1 − 남은/최대) — stroke-dashoffset 산술
function paint() {
countEl!.textContent = String(remaining);
const offset = CIRC * (1 - remaining / MAX_TRIES);
prog!.style.strokeDashoffset = offset.toFixed(2);
root!.classList.toggle(styles.locked, remaining <= 0);
}
function fail() {
if (remaining <= 0) { remaining = MAX_TRIES; paint(); return; }
remaining -= 1;
paint();
}
function onClick() {
root!.classList.remove(styles["is-demo"]);
stopAutoplay();
fail();
}
btn.addEventListener("click", onClick);
paint();
let autoTimer: number | null = null;
function stopAutoplay() { if (autoTimer !== null) { window.clearInterval(autoTimer); autoTimer = null; } }
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (!reduce) { autoTimer = window.setInterval(fail, 380); }
return () => {
stopAutoplay();
btn.removeEventListener("click", onClick);
};
}, []);
return (
<div ref={rootRef} className={`${styles.stage} ${styles.alr} ${styles["is-demo"]}`}>
<div className={styles.ringwrap}>
<svg className={styles.ring} viewBox="0 0 100 100" width={120} height={120}>
<circle className={styles.track} cx={50} cy={50} r={40} />
<circle className={styles.prog} cx={50} cy={50} r={40} />
</svg>
<div className={styles.mid}>
<span className={styles.count}>5</span>
<span className={styles.label}>남은 시도</span>
</div>
</div>
<button className={styles.btn} type="button">로그인 시도</button>
</div>
);
}03 Lockout progress ring — the remaining-tries value is shown as a circular progress value — Measured area 2.46% · moving frames 22/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 UI07 Ring overshoot — a circular progress ring fills by an angle value, then overshoots by an inertia value at completion before settling backFingerprint Scan Animation: 9 Biometric UI Demos
Auth UI06 Signup step progress9 Login Form Design Patterns You Can Copy-Paste
Auth UI04 Magic link — a sent-confirmation card that recomputes remaining time into a ring's arc length9 Login UI Design Patterns (Copy-Paste)