Three donut chart segments trade shares back and forth while the chart turns slowly, a natural placeholder for dashboards and reports. Each segment is an SVG circle with its own dash and offset.
Also known as: pie chart loading animation, dashboard loader, chart placeholder spinner.
<svg class="ldr-donut-chart" viewBox="0 0 48 48" role="status" aria-label="Loading"> <circle class="ldr-donut-chart-a" cx="24" cy="24" r="16" pathLength="100"></circle> <circle class="ldr-donut-chart-b" cx="24" cy="24" r="16" pathLength="100"></circle> <circle class="ldr-donut-chart-c" cx="24" cy="24" r="16" pathLength="100"></circle> </svg>
.ldr-donut-chart {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
width: var(--s);
height: var(--s);
animation: ldr-donut-chart-turn 7.2s linear infinite;
}
.ldr-donut-chart circle {
fill: none;
stroke-width: 8;
animation: 3.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
/* Shares go 50/30/20, then 22/43/35, then 36/18/46, with a gap of 2.5 between segments. */
.ldr-donut-chart .ldr-donut-chart-a { stroke: var(--c); animation-name: ldr-donut-chart-a; }
.ldr-donut-chart .ldr-donut-chart-b { stroke: color-mix(in srgb, var(--ldr-color, #3b82f6) 60%, transparent); animation-name: ldr-donut-chart-b; }
.ldr-donut-chart .ldr-donut-chart-c { stroke: color-mix(in srgb, var(--ldr-color, #3b82f6) 30%, transparent); animation-name: ldr-donut-chart-c; }
@keyframes ldr-donut-chart-turn {
from { transform: rotate(-90deg); }
to { transform: rotate(270deg); }
}
@keyframes ldr-donut-chart-a {
0%, 20%, 100% { stroke-dasharray: 47.5 52.5; stroke-dashoffset: 0; }
33%, 53% { stroke-dasharray: 19.5 80.5; stroke-dashoffset: 0; }
66%, 86% { stroke-dasharray: 33.5 66.5; stroke-dashoffset: 0; }
}
@keyframes ldr-donut-chart-b {
0%, 20%, 100% { stroke-dasharray: 27.5 72.5; stroke-dashoffset: -50; }
33%, 53% { stroke-dasharray: 40.5 59.5; stroke-dashoffset: -22; }
66%, 86% { stroke-dasharray: 15.5 84.5; stroke-dashoffset: -36; }
}
@keyframes ldr-donut-chart-c {
0%, 20%, 100% { stroke-dasharray: 17.5 82.5; stroke-dashoffset: -80; }
33%, 53% { stroke-dasharray: 32.5 67.5; stroke-dashoffset: -65; }
66%, 86% { stroke-dasharray: 43.5 56.5; stroke-dashoffset: -54; }
}
@media (prefers-reduced-motion: reduce) {
.ldr-donut-chart, .ldr-donut-chart *, .ldr-donut-chart::before, .ldr-donut-chart::after, .ldr-donut-chart *::before, .ldr-donut-chart *::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.