Spinners Animation — Reference

Cube

The Cube is a CSS animation component that a pure CSS 3D cube spinner with six semi-transparent faces that rotates simultaneously on the X and Y axes for a satisfying isometric tumble effect. It ships as self-contained HTML and CSS with no external dependencies, making it drop-in ready for any modern web project regardless of framework or build system.

spinnercube3dperspectiveloaderwireframe

When to use the Cube

Performance characteristics

How it compares

Unlike equivalent JavaScript implementations, the Cube does not require any runtime library — there is nothing to install, bundle, or load asynchronously.

Compared to animated GIFs or video embeds, this CSS component is resolution-independent, theme-able via CSS custom properties, and weighs a fraction of the equivalent media file.

Source code

CSS

css
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; }

    .cube {
      animation: cube 2s infinite ease;
      height: 40px;
      width: 40px;
      transform-style: preserve-3d;
      position: relative;
    }

    .cube div {
      background-color: #ffffff22;
      border: 2px solid #ffffff;
      height: 100%;
      position: absolute;
      width: 100%;
    }

    .cube div:nth-of-type(1) { transform: translateZ(calc(40px / -2)) rotateY(180deg); }
    .cube div:nth-of-type(2) { transform: rotateY(-270deg) translateX(50%);  transform-origin: top right; }
    .cube div:nth-of-type(3) { transform: rotateY(270deg)  translateX(-50%); transform-origin: center left; }
    .cube div:nth-of-type(4) { transform: rotateX(90deg)   translateY(-50%); transform-origin: top center; }
    .cube div:nth-of-type(5) { transform: rotateX(-90deg)  translateY(50%);  transform-origin: bottom center; }
    .cube div:nth-of-type(6) { transform: translateZ(calc(40px / 2)); }

    @keyframes cube {
      0%   { transform: rotate(45deg) rotateX(-25deg)  rotateY(25deg); }
      50%  { transform: rotate(45deg) rotateX(-385deg) rotateY(25deg); }
      100% { transform: rotate(45deg) rotateX(-385deg) rotateY(385deg); }
    }

HTML

html
<div class="cube">
    <div></div><div></div><div></div>
    <div></div><div></div><div></div>
  </div>

Full source

html
<!DOCTYPE html>
<html>
<head>
  <style>
    body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; }

    .cube {
      animation: cube 2s infinite ease;
      height: 40px;
      width: 40px;
      transform-style: preserve-3d;
      position: relative;
    }

    .cube div {
      background-color: #ffffff22;
      border: 2px solid #ffffff;
      height: 100%;
      position: absolute;
      width: 100%;
    }

    .cube div:nth-of-type(1) { transform: translateZ(calc(40px / -2)) rotateY(180deg); }
    .cube div:nth-of-type(2) { transform: rotateY(-270deg) translateX(50%);  transform-origin: top right; }
    .cube div:nth-of-type(3) { transform: rotateY(270deg)  translateX(-50%); transform-origin: center left; }
    .cube div:nth-of-type(4) { transform: rotateX(90deg)   translateY(-50%); transform-origin: top center; }
    .cube div:nth-of-type(5) { transform: rotateX(-90deg)  translateY(50%);  transform-origin: bottom center; }
    .cube div:nth-of-type(6) { transform: translateZ(calc(40px / 2)); }

    @keyframes cube {
      0%   { transform: rotate(45deg) rotateX(-25deg)  rotateY(25deg); }
      50%  { transform: rotate(45deg) rotateX(-385deg) rotateY(25deg); }
      100% { transform: rotate(45deg) rotateX(-385deg) rotateY(385deg); }
    }
  </style>
</head>
<body>
  <div class="cube">
    <div></div><div></div><div></div>
    <div></div><div></div><div></div>
  </div>
</body>
</html>

Frequently asked questions

How do I add the Cube to my project?

Copy the full source code from the code block on this page. Paste the <style> block into your stylesheet (or a <style> tag in your HTML head) and the HTML markup into your template. No npm install or build step is required — the animation is self-contained. To customize colors, speed, or size, use Grepped's workspace at grepped.dev/animations/spinners/cube-spinner.

Is the Cube free to use?

Yes. All Grepped preset animations are free to use in personal and commercial projects. You may copy, modify, and redistribute the code without attribution. The only limitation is that you may not resell the presets themselves as part of a competing animation library.

Does the Cube work on mobile browsers?

Yes. The Cube uses standard CSS animations and transforms that are supported in all modern mobile browsers — Chrome for Android, Safari on iOS 9+, Samsung Internet, and Firefox for Android. Where JavaScript is used for interactivity (e.g. cursor effects), it falls back gracefully on touch devices.

Can I customize the Cube's colors, speed, or size?

Yes. Open the live customization workspace at grepped.dev/animations/spinners/cube-spinner to adjust the animation with real-time sliders, color pickers, and toggles — no code required. For deeper changes, the source code uses CSS custom properties (variables) so you can edit them directly in your stylesheet.

Want to customize this animation or generate a new one from a text prompt?

Open in Workspace — it's free