AI CSS Animations

Dot Spinner

Eight dots in a circle, each a little smaller and fainter than the one ahead, rotating as one so the ring reads as a comet with a tail. Sizes are set once and only the wrapper spins.

Also known as: css dot spinner, trailing dots spinner, loading circle with dots.

HTML

<div class="ldr-dot-spinner" 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>
</div>

CSS

.ldr-dot-spinner {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: var(--s);
  height: var(--s);
  animation: ldr-dot-spinner-spin 1.1s linear infinite;
}
.ldr-dot-spinner span {
  position: absolute;
  inset: 0;
  transform: rotate(calc(var(--i) * -45deg));
}
.ldr-dot-spinner span::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(50% - var(--s) / 9);
  width: calc(var(--s) / 4.5);
  height: calc(var(--s) / 4.5);
  border-radius: 50%;
  background: var(--c);
  opacity: calc(1 - var(--i) * 0.11);
  transform: scale(calc(1 - var(--i) * 0.09));
}
@keyframes ldr-dot-spinner-spin {
  to { transform: rotate(360deg); }
}

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

Tailwind CSS version

The same loader using only Tailwind's built-in animation utilities. No custom keyframes or config needed.

<div class="relative h-12 w-12 animate-spin [animation-duration:1.1s]" role="status" aria-label="Loading">
  <span class="absolute inset-0"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 rounded-full bg-blue-500"></span></span>
  <span class="absolute inset-0 -rotate-45"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 scale-[.91] rounded-full bg-blue-500 opacity-[.89]"></span></span>
  <span class="absolute inset-0 -rotate-90"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 scale-[.82] rounded-full bg-blue-500 opacity-[.78]"></span></span>
  <span class="absolute inset-0 -rotate-[135deg]"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 scale-[.73] rounded-full bg-blue-500 opacity-[.67]"></span></span>
  <span class="absolute inset-0 rotate-180"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 scale-[.64] rounded-full bg-blue-500 opacity-[.56]"></span></span>
  <span class="absolute inset-0 rotate-[135deg]"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 scale-[.55] rounded-full bg-blue-500 opacity-[.45]"></span></span>
  <span class="absolute inset-0 rotate-90"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 scale-[.46] rounded-full bg-blue-500 opacity-[.34]"></span></span>
  <span class="absolute inset-0 rotate-45"><span class="absolute left-1/2 top-0 h-2.5 w-2.5 -translate-x-1/2 scale-[.37] rounded-full bg-blue-500 opacity-[.23]"></span></span>
</div>

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