AI CSS Animations

Isometric Cube Loader

Eight hairline cubes burst apart along their diagonals and spring back into one isometric block, the top corner cube capped in the accent. A calm SVG and CSS loading spinner.

Also known as: isometric loader, 3d cube loader css, hairline loader.

HTML

<div class="hln-iso-cube-loader" role="status" aria-label="Loading">
  <svg viewBox="-110 -60 220 120" aria-hidden="true"><g transform="translate(0 2) scale(2.1)"><g class="hln-iso-cube-loader-cube" style="--x: 0; --y: 0"><g><polygon points="-8,-4 0,0 0,-8 -8,-12"/><polygon points="8,-4 0,0 0,-8 8,-12"/><polygon points="0,-16 8,-12 0,-8 -8,-12"/></g></g><g class="hln-iso-cube-loader-cube" style="--x: -6.4; --y: 3.2"><g><polygon points="-16,0 -8,4 -8,-4 -16,-8"/><polygon points="0,0 -8,4 -8,-4 0,-8"/><polygon points="-8,-12 0,-8 -8,-4 -16,-8"/></g></g><g class="hln-iso-cube-loader-cube" style="--x: 6.4; --y: 3.2"><g><polygon points="0,0 8,4 8,-4 0,-8"/><polygon points="16,0 8,4 8,-4 16,-8"/><polygon points="8,-12 16,-8 8,-4 0,-8"/></g></g><g class="hln-iso-cube-loader-cube" style="--x: 0; --y: -6.4"><g><polygon points="-8,-12 0,-8 0,-16 -8,-20"/><polygon points="8,-12 0,-8 0,-16 8,-20"/><polygon points="0,-24 8,-20 0,-16 -8,-20"/></g></g><g class="hln-iso-cube-loader-cube" style="--x: 0; --y: 6.4"><g><polygon points="-8,4 0,8 0,0 -8,-4"/><polygon points="8,4 0,8 0,0 8,-4"/><polygon points="0,-8 8,-4 0,0 -8,-4"/></g></g><g class="hln-iso-cube-loader-cube" style="--x: -6.4; --y: -3.2"><g><polygon points="-16,-8 -8,-4 -8,-12 -16,-16"/><polygon points="0,-8 -8,-4 -8,-12 0,-16"/><polygon points="-8,-20 0,-16 -8,-12 -16,-16"/></g></g><g class="hln-iso-cube-loader-cube" style="--x: 6.4; --y: -3.2"><g><polygon points="0,-8 8,-4 8,-12 0,-16"/><polygon points="16,-8 8,-4 8,-12 16,-16"/><polygon points="8,-20 16,-16 8,-12 0,-16"/></g></g><g class="hln-iso-cube-loader-cube hln-iso-cube-loader-hot" style="--x: 0; --y: 0"><g><polygon points="-8,-4 0,0 0,-8 -8,-12"/><polygon points="8,-4 0,0 0,-8 8,-12"/><polygon points="0,-16 8,-12 0,-8 -8,-12"/></g></g></g></svg>
</div>

CSS

.hln-iso-cube-loader {
  --c: var(--hln-color, #ff4f2e);
  font-size: var(--hln-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 22em;
  height: 12em;
  border-radius: 0.75em;
  background: #f6f5f1;
  overflow: hidden;
  --u: 1px;
}
.hln-iso-cube-loader svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: #ffffff;
  stroke: #1c1d21;
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.hln-iso-cube-loader svg * {
  vector-effect: non-scaling-stroke;
}
.hln-iso-cube-loader .hln-iso-cube-loader-cube {
  animation: hln-iso-cube-loader-burst 3.2s infinite;
}
.hln-iso-cube-loader .hln-iso-cube-loader-hot polygon:last-child {
  fill: var(--c);
}
@keyframes hln-iso-cube-loader-burst {
  0% { translate: 0 0; }
  10% { translate: calc(var(--x) * 0 * var(--u)) calc(var(--y) * 0 * var(--u)); animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1); }
  23.2% { translate: calc(var(--x) * 1.08 * var(--u)) calc(var(--y) * 1.08 * var(--u)); animation-timing-function: ease-in-out; }
  29.2% { translate: calc(var(--x) * 0.98 * var(--u)) calc(var(--y) * 0.98 * var(--u)); animation-timing-function: ease-in-out; }
  34% { translate: calc(var(--x) * 1 * var(--u)) calc(var(--y) * 1 * var(--u)); }
  58% { translate: calc(var(--x) * 1 * var(--u)) calc(var(--y) * 1 * var(--u)); animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1); }
  72.3% { translate: calc(var(--x) * -0.08000000000000007 * var(--u)) calc(var(--y) * -0.08000000000000007 * var(--u)); animation-timing-function: ease-in-out; }
  78.8% { translate: calc(var(--x) * 0.020000000000000018 * var(--u)) calc(var(--y) * 0.020000000000000018 * var(--u)); animation-timing-function: ease-in-out; }
  84% { translate: calc(var(--x) * 0 * var(--u)) calc(var(--y) * 0 * var(--u)); }
  100% { translate: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hln-iso-cube-loader * {
    animation: none !important;
  }
  .hln-iso-cube-loader .hln-iso-cube-loader-cube { translate: calc(var(--x) * 0.5 * var(--u)) calc(var(--y) * 0.5 * var(--u)); }
}

@media (prefers-reduced-motion: reduce) {
  .hln-iso-cube-loader, .hln-iso-cube-loader *, .hln-iso-cube-loader::before, .hln-iso-cube-loader::after, .hln-iso-cube-loader *::before, .hln-iso-cube-loader *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hln-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hln-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hairline animations