AI CSS Animations

Wireframe Cube Loader

A wireframe cube tumbles on two axes while a smaller tinted cube inside turns the opposite way, like a tesseract sketch. Edges are borders on transparent faces in one preserve-3d scene.

Also known as: tesseract loader, cube in cube loader, 3d wireframe cube.

HTML

<div class="ldr-wireframe-cube" role="status" aria-label="Loading">
  <div class="ldr-wireframe-cube-outer"><span></span><span></span><span></span><span></span><span></span><span></span></div>
  <div class="ldr-wireframe-cube-inner"><span></span><span></span><span></span><span></span><span></span><span></span></div>
</div>

CSS

.ldr-wireframe-cube {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: var(--s);
  height: var(--s);
  perspective: calc(var(--s) * 4);
  transform-style: preserve-3d;
}
.ldr-wireframe-cube-outer,
.ldr-wireframe-cube-inner {
  --e: calc(var(--s) * 0.56);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--e);
  height: var(--e);
  margin: calc(var(--e) / -2) 0 0 calc(var(--e) / -2);
  transform-style: preserve-3d;
  animation: ldr-wireframe-cube-tumble 4.8s linear infinite;
}
.ldr-wireframe-cube-inner {
  --e: calc(var(--s) * 0.26);
  animation-direction: reverse;
}
.ldr-wireframe-cube span {
  position: absolute;
  inset: 0;
  border: calc(var(--s) / 28) solid var(--c);
}
.ldr-wireframe-cube-inner span {
  border-width: calc(var(--s) / 40);
  border-color: color-mix(in srgb, var(--ldr-color, #3b82f6) 80%, transparent);
  background: color-mix(in srgb, var(--ldr-color, #3b82f6) 26%, transparent);
}
.ldr-wireframe-cube span:nth-child(1) { transform: translateZ(calc(var(--e) / 2)); }
.ldr-wireframe-cube span:nth-child(2) { transform: rotateY(90deg) translateZ(calc(var(--e) / 2)); }
.ldr-wireframe-cube span:nth-child(3) { transform: rotateY(180deg) translateZ(calc(var(--e) / 2)); }
.ldr-wireframe-cube span:nth-child(4) { transform: rotateY(-90deg) translateZ(calc(var(--e) / 2)); }
.ldr-wireframe-cube span:nth-child(5) { transform: rotateX(90deg) translateZ(calc(var(--e) / 2)); }
.ldr-wireframe-cube span:nth-child(6) { transform: rotateX(-90deg) translateZ(calc(var(--e) / 2)); }
@keyframes ldr-wireframe-cube-tumble {
  from { transform: rotateX(0deg) rotateY(0deg); }
  to   { transform: rotateX(360deg) rotateY(360deg); }
}

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