AI CSS Animations

Color Cycling Spinner

A spinner whose color slides through the whole spectrum as it turns, using a hue-rotate filter on top of your accent color. Set the accent and it cycles from there.

Also known as: rainbow spinner, color changing loader.

HTML

<div class="ldr-hue-ring" role="status" aria-label="Loading"></div>

CSS

.ldr-hue-ring {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  width: var(--s);
  height: var(--s);
  border: calc(var(--s) / 10) solid transparent;
  border-top-color: var(--c);
  border-right-color: var(--c);
  border-radius: 50%;
  animation: ldr-hue-ring-spin 1s linear infinite, ldr-hue-ring-hue 3s linear infinite;
}
@keyframes ldr-hue-ring-spin {
  to { transform: rotate(360deg); }
}
@keyframes ldr-hue-ring-hue {
  to { filter: hue-rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-hue-ring, .ldr-hue-ring *, .ldr-hue-ring::before, .ldr-hue-ring::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