Twelve short bars ride a traveling sine wave, stretching as they pass the middle where they move fastest. Sine easing on each quarter keeps the curve smooth; the phase comes from one --i index.
Also known as: wave bars loader, snake wave loader, sine wave animation css.
<div class="ldr-sine-wave-bars" role="status" aria-label="Loading"> <span style="--i: 0"></span><span style="--i: 1"></span><span style="--i: 2"></span><span style="--i: 3"></span> <span style="--i: 4"></span><span style="--i: 5"></span><span style="--i: 6"></span><span style="--i: 7"></span> <span style="--i: 8"></span><span style="--i: 9"></span><span style="--i: 10"></span><span style="--i: 11"></span> </div>
.ldr-sine-wave-bars {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
display: flex;
align-items: center;
gap: calc(var(--s) / 16);
height: var(--s);
}
.ldr-sine-wave-bars span {
width: calc(var(--s) / 16);
height: calc(var(--s) / 3.2);
border-radius: var(--s);
background: var(--c);
animation: ldr-sine-wave-bars-sway 1.6s infinite;
animation-delay: calc(var(--i) * 0.1333s - 1.6s);
}
@keyframes ldr-sine-wave-bars-sway {
0%, 100% { transform: translateY(calc(var(--s) * -0.3)) scaleY(0.85); animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0); }
25% { transform: translateY(0) scaleY(1.2); animation-timing-function: cubic-bezier(0.61, 1, 0.88, 1); }
50% { transform: translateY(calc(var(--s) * 0.3)) scaleY(0.85); animation-timing-function: cubic-bezier(0.12, 0, 0.39, 0); }
75% { transform: translateY(0) scaleY(1.2); animation-timing-function: cubic-bezier(0.61, 1, 0.88, 1); }
}
@media (prefers-reduced-motion: reduce) {
.ldr-sine-wave-bars, .ldr-sine-wave-bars *, .ldr-sine-wave-bars::before, .ldr-sine-wave-bars::after, .ldr-sine-wave-bars *::before, .ldr-sine-wave-bars *::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.