Four rounded squares orbit a shared center while each one breathes in and out. Feels like a logo mark coming together, so it works well as a brand loader.
<div class="ldr-four-squares" role="status" aria-label="Loading"> <span></span><span></span><span></span><span></span> </div>
.ldr-four-squares {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
position: relative;
width: var(--s);
height: var(--s);
animation: ldr-four-squares-spin 2s ease-in-out infinite;
}
.ldr-four-squares span {
position: absolute;
width: 44%;
height: 44%;
border-radius: 15%;
background: var(--c);
animation: ldr-four-squares-breathe 2s ease-in-out infinite;
}
.ldr-four-squares span:nth-child(1) { top: 0; left: 0; }
.ldr-four-squares span:nth-child(2) { top: 0; right: 0; animation-delay: -0.5s; }
.ldr-four-squares span:nth-child(3) { bottom: 0; right: 0; animation-delay: -1s; }
.ldr-four-squares span:nth-child(4) { bottom: 0; left: 0; animation-delay: -1.5s; }
@keyframes ldr-four-squares-spin {
to { transform: rotate(360deg); }
}
@keyframes ldr-four-squares-breathe {
0%, 100% { transform: scale(1); }
50% { transform: scale(0.55); }
}
@media (prefers-reduced-motion: reduce) {
.ldr-four-squares, .ldr-four-squares *, .ldr-four-squares::before, .ldr-four-squares::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.