@property --p {
syntax: "<integer>";
inherits: true;
initial-value: 0;
}
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
background: #f4f3ef;
color: #17181c;
font: 14px/1.4 system-ui, sans-serif;
}
.usage {
width: min(560px, 100% - 32px);
padding: 24px;
border: 1px solid #e3e0d9;
border-radius: 18px;
background: #fff;
}
.usage__title {
margin: 0 0 18px;
font-size: 1rem;
}
.usage__rings {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 16px;
}
.ring {
display: grid;
justify-items: center;
gap: 10px;
margin: 0;
text-align: center;
}
.ring__dial {
--p: var(--value);
position: relative;
display: grid;
place-items: center;
width: 112px;
aspect-ratio: 1;
counter-reset: p var(--p);
animation: fill 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.ring__dial::before {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
background: conic-gradient(var(--color) calc(var(--p) * 1%), #eceae4 0);
mask: radial-gradient(circle, transparent 0 calc(50% - 11px), #000 calc(50% - 10px));
}
.ring__dial::after {
content: counter(p) "%";
font-size: 1.35rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
letter-spacing: -0.02em;
}
.ring figcaption {
font-weight: 600;
}
.ring figcaption span {
display: block;
color: #73767f;
font-weight: 400;
font-size: 0.8rem;
}
@keyframes fill {
from {
--p: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.ring__dial {
animation: none;
}
}Usage
Set each ring's target with
--value. --p is a registered integer, so it animates, and the same value draws the conic arc and feeds the counter that prints the number.