AI CSS Animations

Stack Shuffle Loader

Three lines step down a slot at a time: the bottom one slides out, a fresh one slides in on top, and each line dims as it ages. Reads as a feed or list refreshing. One keyframe, three offsets.

Also known as: list refresh animation, sliding lines loader, feed loading animation.

HTML

<div class="ldr-stack-shuffle" role="status" aria-label="Loading">
  <span style="--w: 100%"></span><span style="--w: 68%"></span><span style="--w: 84%"></span>
</div>

CSS

.ldr-stack-shuffle {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: calc(var(--s) * 1.2);
  height: calc(var(--s) * 0.78);
}
.ldr-stack-shuffle span {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--w);
  height: calc(var(--s) / 7);
  border-radius: var(--s);
  background: var(--c);
  animation: ldr-stack-shuffle-cycle 2.4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.ldr-stack-shuffle span:nth-child(2) { animation-delay: -0.8s; }
.ldr-stack-shuffle span:nth-child(3) { animation-delay: -1.6s; }
@keyframes ldr-stack-shuffle-cycle {
  0%       { transform: translate(-30%, 0); opacity: 0; }
  8%, 25%  { transform: translate(0, 0); opacity: 1; }
  33%, 58% { transform: translate(0, calc(var(--s) * 0.32)); opacity: 0.55; }
  66%, 91% { transform: translate(0, calc(var(--s) * 0.64)); opacity: 0.25; }
  100%     { transform: translate(30%, calc(var(--s) * 0.64)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-stack-shuffle, .ldr-stack-shuffle *, .ldr-stack-shuffle::before, .ldr-stack-shuffle::after, .ldr-stack-shuffle *::before, .ldr-stack-shuffle *::after {
    animation-duration: 3s;
  }
}

Customizing this loader

  • Color: set --ldr-color on the element or a parent. Currently previewing #3b82f6.
  • Size: set --ldr-size. Every dimension in the snippet is derived from it. Currently previewing 64px.
  • Speed: change the duration on the animation shorthand. Delays on the children are relative, so they keep their rhythm.
  • Accessibility: the root carries 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.

Similar loaders