AI CSS Animations

Combination Lock Spinner

Three notched rings scramble in different directions, then line up so the notches form one open channel and the centre lights, like a lock clicking open. Angles come from custom properties.

Also known as: aligning rings loader, triple ring spinner, concentric rings with gap.

HTML

<svg class="ldr-aligning-rings" viewBox="0 0 48 48" role="status" aria-label="Loading">
  <circle class="ldr-aligning-rings-outer" cx="24" cy="24" r="20" pathLength="100"></circle>
  <circle class="ldr-aligning-rings-middle" cx="24" cy="24" r="14" pathLength="100"></circle>
  <circle class="ldr-aligning-rings-inner" cx="24" cy="24" r="8" pathLength="100"></circle>
  <circle class="ldr-aligning-rings-dot" cx="24" cy="24" r="2.5"></circle>
</svg>

CSS

.ldr-aligning-rings {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  width: var(--s);
  height: var(--s);
}
.ldr-aligning-rings circle {
  fill: none;
  stroke: var(--c);
  stroke-width: 3.5;
  stroke-linecap: round;
  transform-origin: center;
  animation: ldr-aligning-rings-turn 3s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
/* Every gap is the same width in pixels and sits at 12 o'clock (75 of 100) when aligned. */
.ldr-aligning-rings-outer  { stroke-dasharray: 93 7;  stroke-dashoffset: -78.5; --a: 200deg;  --b: -70deg; --z: 360deg; }
.ldr-aligning-rings-middle { stroke-dasharray: 90 10; stroke-dashoffset: -80;   --a: -150deg; --b: 95deg;  --z: 0deg; opacity: 0.75; }
.ldr-aligning-rings-inner  { stroke-dasharray: 83 17; stroke-dashoffset: -83.5; --a: 110deg;  --b: -160deg; --z: -360deg; opacity: 0.5; }
.ldr-aligning-rings .ldr-aligning-rings-dot {
  fill: var(--c);
  stroke: none;
  animation-name: ldr-aligning-rings-lit;
}
@keyframes ldr-aligning-rings-turn {
  0%, 12%  { transform: rotate(0deg); }
  38%, 48% { transform: rotate(var(--a)); }
  74%, 84% { transform: rotate(var(--b)); }
  100%     { transform: rotate(var(--z)); }
}
@keyframes ldr-aligning-rings-lit {
  0%, 12%   { opacity: 1; transform: scale(1.2); }
  22%, 90%  { opacity: 0.25; transform: scale(0.8); }
  100%      { opacity: 1; transform: scale(1.2); }
}

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