Three dots trade places like a shell game: one arcs over the top while its partner ducks underneath. Six swaps bring every dot home, and sine easing on each axis keeps the arcs round.
Also known as: juggling dots loader, swapping dots animation, shell game loader.
<div class="ldr-shuffling-dots" role="status" aria-label="Loading"> <span></span><span></span><span></span> </div>
.ldr-shuffling-dots {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
--d: calc(var(--s) / 4.5);
--g: calc(var(--s) / 2.4);
position: relative;
width: calc(var(--g) * 2 + var(--d));
height: var(--s);
}
.ldr-shuffling-dots span {
position: absolute;
top: calc(50% - var(--d) / 2);
left: 0;
width: var(--d);
height: var(--d);
animation: ldr-shuffling-dots-x 2.4s cubic-bezier(0.37, 0, 0.63, 1) infinite;
}
.ldr-shuffling-dots span::before {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
background: var(--c);
animation: ldr-shuffling-dots-y 2.4s infinite;
}
.ldr-shuffling-dots span:nth-child(2),
.ldr-shuffling-dots span:nth-child(2)::before { animation-delay: -1.6s; }
.ldr-shuffling-dots span:nth-child(3),
.ldr-shuffling-dots span:nth-child(3)::before { animation-delay: -0.8s; }
@keyframes ldr-shuffling-dots-x {
0%, 80%, 100% { transform: translateX(0); }
13.33%, 16.67%, 63.33%, 66.67% { transform: translateX(var(--g)); }
30%, 50% { transform: translateX(calc(var(--g) * 2)); }
}
@keyframes ldr-shuffling-dots-y {
0%, 13.33%, 16.67%, 30%, 50%, 63.33%, 66.67%, 80%, 100% {
transform: translateY(0);
animation-timing-function: cubic-bezier(0.61, 1, 0.88, 1);
}
6.67%, 23.33% {
transform: translateY(calc(var(--g) / -2));
animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
}
56.67%, 73.33% {
transform: translateY(calc(var(--g) / 2));
animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0);
}
}
@media (prefers-reduced-motion: reduce) {
.ldr-shuffling-dots, .ldr-shuffling-dots *, .ldr-shuffling-dots::before, .ldr-shuffling-dots::after, .ldr-shuffling-dots *::before, .ldr-shuffling-dots *::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.