A ring that fills clockwise while the number in the middle counts up to 100%. The counter is pure CSS using a registered custom property, so there is no JavaScript to wire up.
Also known as: percentage loader, radial progress, progress ring.
<div class="ldr-circular-progress" role="progressbar" aria-label="Loading"></div>
@property --ldr-p {
syntax: "<integer>";
initial-value: 0;
inherits: true;
}
.ldr-circular-progress {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
--t: calc(var(--s) / 9);
position: relative;
display: grid;
place-items: center;
width: var(--s);
height: var(--s);
font: 600 calc(var(--s) / 4.5) system-ui, sans-serif;
color: var(--c);
animation: ldr-circular-progress-count 3s ease-in-out infinite;
}
.ldr-circular-progress::before {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
background: conic-gradient(var(--c) calc(var(--ldr-p) * 1%), color-mix(in srgb, var(--ldr-color, #3b82f6) 15%, transparent) 0);
-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--t)), #000 calc(100% - var(--t) + 1px));
mask: radial-gradient(farthest-side, transparent calc(100% - var(--t)), #000 calc(100% - var(--t) + 1px));
}
.ldr-circular-progress::after {
counter-reset: ldr-p var(--ldr-p);
content: counter(ldr-p) "%";
}
@keyframes ldr-circular-progress-count {
0% { --ldr-p: 0; }
85%, 100% { --ldr-p: 100; }
}
@media (prefers-reduced-motion: reduce) {
.ldr-circular-progress, .ldr-circular-progress *, .ldr-circular-progress::before, .ldr-circular-progress::after {
animation-duration: 3s;
}
}--ldr-color on the element or a parent.
Currently previewing #3b82f6.--ldr-size. Every dimension in the snippet is
derived from it. Currently previewing 64px.animation shorthand.
Delays on the children are relative, so they keep their rhythm.role="status" and an
aria-label so screen readers announce the wait. The reduced-motion rule
at the end slows the animation for users who asked for less motion.