AI CSS Animations

Epicycle Orbit Loader

A moon rides a small circle whose center rides a big one, like Ptolemy's epicycles, tracing a three-lobed loop with a fading trail. Just two nested rotations per dot.

Also known as: spirograph loader, planet and moon orbit, epicycle animation.

HTML

<div class="ldr-epicycle" role="status" aria-label="Loading">
  <span style="--i: 0"><span></span></span>
  <span style="--i: 1"><span></span></span>
  <span style="--i: 2"><span></span></span>
  <span style="--i: 3"><span></span></span>
  <span style="--i: 4"><span></span></span>
</div>

CSS

.ldr-epicycle {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: var(--s);
  height: var(--s);
}
.ldr-epicycle::before {
  content: "";
  position: absolute;
  inset: 20%;
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--ldr-color, #3b82f6) 30%, transparent);
  border-radius: 50%;
}
.ldr-epicycle::after {
  content: "";
  position: absolute;
  inset: 44%;
  border-radius: 50%;
  background: var(--c);
}
.ldr-epicycle > span {
  position: absolute;
  inset: 0;
  animation: ldr-epicycle-turn 3s linear infinite;
  animation-delay: calc(var(--i) * 0.05s - 3s);
}
.ldr-epicycle > span > span {
  position: absolute;
  top: 20%;
  left: 50%;
  animation: ldr-epicycle-turn 1s linear infinite reverse;
  animation-delay: inherit;
}
.ldr-epicycle > span > span::before {
  --d: calc(var(--s) * (0.14 - var(--i) * 0.018));
  content: "";
  position: absolute;
  top: calc(var(--s) * -0.17 - var(--d) / 2);
  left: calc(var(--d) / -2);
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: var(--c);
  opacity: calc(1 - var(--i) * 0.18);
}
/* The small circle the moon rides, drawn once. */
.ldr-epicycle > span:first-child > span::after {
  content: "";
  position: absolute;
  top: calc(var(--s) * -0.17);
  left: calc(var(--s) * -0.17);
  width: calc(var(--s) * 0.34);
  height: calc(var(--s) * 0.34);
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--ldr-color, #3b82f6) 35%, transparent);
  border-radius: 50%;
}
@keyframes ldr-epicycle-turn {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-epicycle, .ldr-epicycle *, .ldr-epicycle::before, .ldr-epicycle::after, .ldr-epicycle *::before, .ldr-epicycle *::after {
    animation-duration: 3s;
  }
}

Tailwind CSS version

The same loader using only Tailwind's built-in animation utilities. No custom keyframes or config needed.

<div class="relative h-12 w-12" role="status" aria-label="Loading">
  <div class="absolute inset-[20%] rounded-full border border-blue-500/30"></div>
  <div class="absolute inset-[44%] rounded-full bg-blue-500"></div>
  <div class="absolute inset-0 animate-[spin_3s_linear_infinite]">
    <div class="absolute left-1/2 top-[20%] animate-[spin_1s_linear_infinite_reverse]">
      <div class="absolute -left-2 -top-2 h-4 w-4 rounded-full border border-blue-500/30"></div>
      <div class="absolute -left-[3px] -top-[11px] h-1.5 w-1.5 rounded-full bg-blue-500"></div>
    </div>
  </div>
  <div class="absolute inset-0 animate-[spin_3s_linear_infinite] [animation-delay:-2.9s]">
    <div class="absolute left-1/2 top-[20%] animate-[spin_1s_linear_infinite_reverse] [animation-delay:-2.9s]">
      <div class="absolute -left-[2px] -top-[10px] h-1 w-1 rounded-full bg-blue-500 opacity-50"></div>
    </div>
  </div>
  <div class="absolute inset-0 animate-[spin_3s_linear_infinite] [animation-delay:-2.8s]">
    <div class="absolute left-1/2 top-[20%] animate-[spin_1s_linear_infinite_reverse] [animation-delay:-2.8s]">
      <div class="absolute -left-[2px] -top-[10px] h-1 w-1 rounded-full bg-blue-500 opacity-25"></div>
    </div>
  </div>
</div>

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