A ball drops onto a soft shadow, squashes, and springs back up. A little Disney squash-and-stretch goes a long way toward making a wait feel shorter.
<div class="ldr-bouncing-ball" role="status" aria-label="Loading"></div>
.ldr-bouncing-ball {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
position: relative;
width: var(--s);
height: calc(var(--s) * 1.6);
}
.ldr-bouncing-ball::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: var(--s);
height: var(--s);
border-radius: 50%;
background: var(--c);
animation: ldr-bouncing-ball-drop 0.55s cubic-bezier(0.5, 0.05, 1, 0.5) infinite alternate;
}
.ldr-bouncing-ball::after {
content: "";
position: absolute;
bottom: 0;
left: 15%;
width: 70%;
height: calc(var(--s) / 6);
border-radius: 50%;
background: color-mix(in srgb, var(--ldr-color, #3b82f6) 30%, transparent);
animation: ldr-bouncing-ball-shadow 0.55s cubic-bezier(0.5, 0.05, 1, 0.5) infinite alternate;
}
@keyframes ldr-bouncing-ball-drop {
from { transform: translateY(0) scale(1, 1); }
to { transform: translateY(calc(var(--s) * 0.45)) scale(1.08, 0.88); }
}
@keyframes ldr-bouncing-ball-shadow {
from { transform: scale(0.5); opacity: 0.4; }
to { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.ldr-bouncing-ball, .ldr-bouncing-ball *, .ldr-bouncing-ball::before, .ldr-bouncing-ball::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.