AI CSS Animations

Draw and Erase Circle Loader

A stroke draws a full circle from 12 o'clock, pauses, then its tail chases round and erases it. Only stroke-dashoffset moves, on one SVG circle with pathLength set to 100.

Also known as: stroke draw circle, svg circle drawing animation, circle stroke loader.

HTML

<svg class="ldr-circle-draw" viewBox="0 0 48 48" role="status" aria-label="Loading">
  <circle cx="24" cy="24" r="19" pathLength="100"></circle>
</svg>

CSS

.ldr-circle-draw {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  width: var(--s);
  height: var(--s);
  transform: rotate(-90deg);
}
/* Dash 100, gap 120: offset 105 hides it, 0 shows all of it, -105 has run past the end. */
.ldr-circle-draw circle {
  fill: none;
  stroke: var(--c);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-dasharray: 100 120;
  animation: ldr-circle-draw-trace 1.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes ldr-circle-draw-trace {
  0%       { stroke-dashoffset: 105; }
  45%, 55% { stroke-dashoffset: 0; }
  100%     { stroke-dashoffset: -105; }
}

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