AI CSS Animations

3D Pyramid Loader

A four-sided pyramid turning slowly in 3D, each face a clip-path triangle tilted on its base edge. Opaque faces in stepped shades of the accent, so it reads as solid without any lighting math.

Also known as: rotating pyramid, css 3d pyramid, spinning pyramid loader.

HTML

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

CSS

.ldr-pyramid-3d {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  --b: calc(var(--s) * 0.74);
  position: relative;
  width: var(--s);
  height: var(--s);
  perspective: calc(var(--s) * 5);
}
.ldr-pyramid-3d > div {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  animation: ldr-pyramid-3d-turn 3.2s linear infinite;
}
.ldr-pyramid-3d span {
  position: absolute;
  left: calc(50% - var(--b) / 2);
  bottom: calc(var(--s) * 0.19);
  width: var(--b);
  height: var(--b);
  background: var(--c);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  backface-visibility: hidden;
  transform-origin: 50% 100%;
  transform: rotateY(calc(var(--i) * 90deg)) translateZ(calc(var(--b) / 2)) rotateX(30deg);
}
.ldr-pyramid-3d span:nth-child(2) { background: color-mix(in srgb, var(--c) 70%, #000); }
.ldr-pyramid-3d span:nth-child(3) { background: color-mix(in srgb, var(--c) 50%, #000); }
.ldr-pyramid-3d span:nth-child(4) { background: color-mix(in srgb, var(--c) 65%, #fff); }
@keyframes ldr-pyramid-3d-turn {
  from { transform: rotateX(-16deg) rotateY(0deg); }
  to   { transform: rotateX(-16deg) rotateY(360deg); }
}

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