Two squares chase each other around the corners of a box, shrinking on each side and turning a quarter per leg. A SpinKit favorite, redone with one transform list so every leg interpolates cleanly.
Also known as: spinkit wandering cubes, chasing squares loader, moving squares spinner.
<div class="ldr-wandering-cubes" role="status" aria-label="Loading"> <span></span><span></span> </div>
.ldr-wandering-cubes {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
--d: calc(var(--s) * 0.64);
position: relative;
width: var(--s);
height: var(--s);
}
.ldr-wandering-cubes span {
position: absolute;
top: 0;
left: 0;
width: calc(var(--s) * 0.36);
height: calc(var(--s) * 0.36);
border-radius: calc(var(--s) / 20);
background: var(--c);
animation: ldr-wandering-cubes-move 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.ldr-wandering-cubes span:nth-child(2) {
background: color-mix(in srgb, var(--ldr-color, #3b82f6) 55%, transparent);
animation-delay: -0.9s;
}
@keyframes ldr-wandering-cubes-move {
0% { transform: translate(0, 0) rotate(0deg) scale(1); }
25% { transform: translate(var(--d), 0) rotate(-90deg) scale(0.5); }
50% { transform: translate(var(--d), var(--d)) rotate(-180deg) scale(1); }
75% { transform: translate(0, var(--d)) rotate(-270deg) scale(0.5); }
100% { transform: translate(0, 0) rotate(-360deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
.ldr-wandering-cubes, .ldr-wandering-cubes *, .ldr-wandering-cubes::before, .ldr-wandering-cubes::after, .ldr-wandering-cubes *::before, .ldr-wandering-cubes *::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.