AI CSS Animations

Three Triangles Loader

Three triangles form one larger triangle, and each spins a third of a turn in place, ducking small mid-spin so it clears its neighbors. The turn is invisible at rest, so only the motion shows.

Also known as: triangle loader, spinning triangles, sierpinski triangle loader.

HTML

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

CSS

.ldr-triangle-trio {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  --a: calc(var(--s) * 0.52);
  --h: calc(var(--a) * 0.866);
  --g: calc(var(--s) * 0.05);
  position: relative;
  width: calc(var(--a) * 2 + var(--g));
  height: calc(var(--h) * 2 + var(--g));
}
.ldr-triangle-trio span {
  position: absolute;
  bottom: 0;
  width: var(--a);
  height: var(--h);
  background: var(--c);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform-origin: 50% 66.67%;
  animation: ldr-triangle-trio-spin 1.8s infinite;
}
.ldr-triangle-trio span:nth-child(1) {
  top: 0;
  bottom: auto;
  left: calc(var(--a) / 2 + var(--g) / 2);
}
.ldr-triangle-trio span:nth-child(2) {
  right: 0;
  background: color-mix(in srgb, var(--c) 72%, #000);
  animation-delay: 0.2s;
}
.ldr-triangle-trio span:nth-child(3) {
  left: 0;
  background: color-mix(in srgb, var(--c) 60%, #fff);
  animation-delay: 0.4s;
}
@keyframes ldr-triangle-trio-spin {
  0%        { transform: rotate(0deg) scale(1); animation-timing-function: cubic-bezier(0.5, 0, 0.75, 0); }
  16%       { transform: rotate(60deg) scale(0.5); animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1); }
  34%, 100% { transform: rotate(120deg) scale(1); }
}

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