AI CSS Animations

Spokes Spinner

Eight rounded spokes fade in turn around a center point, the pattern iOS and macOS use for activity indicators. Rotation is faked with opacity, so it is very cheap to render.

Also known as: iOS spinner, Apple activity indicator.

HTML

<div class="ldr-spokes" role="status" aria-label="Loading">
  <span></span><span></span><span></span><span></span>
  <span></span><span></span><span></span><span></span>
</div>

CSS

.ldr-spokes {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: var(--s);
  height: var(--s);
}
.ldr-spokes span {
  position: absolute;
  top: 0;
  left: calc(50% - var(--s) / 20);
  width: calc(var(--s) / 10);
  height: calc(var(--s) / 3.5);
  border-radius: 999px;
  background: var(--c);
  transform-origin: 50% calc(var(--s) / 2);
  animation: ldr-spokes-fade 1s linear infinite;
}
.ldr-spokes span:nth-child(1) { transform: rotate(0deg);   animation-delay: -0.875s; }
.ldr-spokes span:nth-child(2) { transform: rotate(45deg);  animation-delay: -0.75s; }
.ldr-spokes span:nth-child(3) { transform: rotate(90deg);  animation-delay: -0.625s; }
.ldr-spokes span:nth-child(4) { transform: rotate(135deg); animation-delay: -0.5s; }
.ldr-spokes span:nth-child(5) { transform: rotate(180deg); animation-delay: -0.375s; }
.ldr-spokes span:nth-child(6) { transform: rotate(225deg); animation-delay: -0.25s; }
.ldr-spokes span:nth-child(7) { transform: rotate(270deg); animation-delay: -0.125s; }
.ldr-spokes span:nth-child(8) { transform: rotate(315deg); animation-delay: 0s; }
@keyframes ldr-spokes-fade {
  0%   { opacity: 1; }
  100% { opacity: 0.15; }
}

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