AI CSS Animations

Material Design Spinner

The Android and Google-apps spinner: an arc that grows and shrinks while the whole ring rotates. An SVG circle with an animated dash, styled entirely from CSS.

Also known as: Android spinner, Google circular progress indicator.

HTML

<svg class="ldr-material-spinner" viewBox="0 0 50 50" role="status" aria-label="Loading">
  <circle cx="25" cy="25" r="20" fill="none" stroke-width="5"></circle>
</svg>

CSS

.ldr-material-spinner {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  width: var(--s);
  height: var(--s);
  animation: ldr-material-spinner-rotate 2s linear infinite;
}
.ldr-material-spinner circle {
  stroke: var(--c);
  stroke-linecap: round;
  stroke-dasharray: 1, 200;
  stroke-dashoffset: 0;
  animation: ldr-material-spinner-dash 1.5s ease-in-out infinite;
}
@keyframes ldr-material-spinner-rotate {
  to { transform: rotate(360deg); }
}
@keyframes ldr-material-spinner-dash {
  0%   { stroke-dasharray: 1, 200;  stroke-dashoffset: 0; }
  50%  { stroke-dasharray: 90, 200; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 200; stroke-dashoffset: -124; }
}

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