AI CSS Animations

Tumbling Cube Loader

An isometric cube hops, stretching on take-off and squashing on landing, and tumbles a third of a turn in the air so its three shaded faces trade places. One hexagon clip-path with a conic-gradient.

Also known as: isometric cube loader, bouncing cube loader, hopping cube animation.

HTML

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

CSS

.ldr-tumbling-cube {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  --w: calc(var(--s) * 0.56);
  position: relative;
  width: var(--s);
  height: calc(var(--s) * 1.3);
}
.ldr-tumbling-cube::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(var(--s) * 0.04);
  width: calc(var(--s) * 0.62);
  height: calc(var(--s) * 0.1);
  margin-left: calc(var(--s) * -0.31);
  border-radius: 50%;
  background: color-mix(in srgb, var(--ldr-color, #3b82f6) 22%, transparent);
  animation: ldr-tumbling-cube-shadow 0.8s infinite;
}
.ldr-tumbling-cube span {
  position: absolute;
  left: 50%;
  bottom: calc(var(--s) * 0.08);
  width: var(--w);
  height: calc(var(--w) * 1.1547);
  margin-left: calc(var(--w) / -2);
  transform-origin: 50% 100%;
  animation: ldr-tumbling-cube-hop 0.8s infinite;
}
.ldr-tumbling-cube span::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: conic-gradient(from -60deg, color-mix(in srgb, var(--c) 55%, #fff) 0 120deg, var(--c) 0 240deg, color-mix(in srgb, var(--c) 62%, #000) 0);
  animation: ldr-tumbling-cube-turn 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes ldr-tumbling-cube-hop {
  0%   { transform: translateY(0) scale(1.14, 0.82); animation-timing-function: cubic-bezier(0.3, 0, 0.5, 1); }
  12%  { transform: translateY(0) scale(0.9, 1.1); animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1); }
  50%  { transform: translateY(calc(var(--s) * -0.42)) scale(1, 1); animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  88%  { transform: translateY(0) scale(0.94, 1.06); animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1); }
  100% { transform: translateY(0) scale(1.14, 0.82); }
}
@keyframes ldr-tumbling-cube-turn {
  0%, 4%     { transform: rotate(0deg); }
  29%, 37%   { transform: rotate(120deg); }
  62%, 70%   { transform: rotate(240deg); }
  96%, 100%  { transform: rotate(360deg); }
}
@keyframes ldr-tumbling-cube-shadow {
  0%, 100% { transform: scale(1.1); opacity: 1; }
  50%      { transform: scale(0.55); opacity: 0.45; }
}

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