AI CSS Animations

Origami Fold Loader

A paper diamond folds in half across one diagonal, opens, then folds across the other, showing its paler back while folded. Each quarter is two-sided through backface-visibility.

Also known as: paper fold loader, folding paper animation, fold diamond loader.

HTML

<div class="ldr-origami-fold" role="status" aria-label="Loading">
  <span></span><span></span><span></span><span></span>
</div>

CSS

.ldr-origami-fold {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: var(--s);
  height: var(--s);
  perspective: calc(var(--s) * 3);
}
.ldr-origami-fold span {
  --a: 0;
  --b: 0;
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  animation: ldr-origami-fold-fold 3.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.ldr-origami-fold span::before,
.ldr-origami-fold span::after {
  content: "";
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}
.ldr-origami-fold span::before {
  background: var(--c);
  clip-path: var(--p);
}
.ldr-origami-fold span::after {
  background: color-mix(in srgb, var(--c) 55%, #fff);
  clip-path: var(--q);
  transform: rotateY(180deg);
}
.ldr-origami-fold span:nth-child(1) {
  --p: polygon(100% 50%, 50% 100%, 50% 50%);
  --q: polygon(0 50%, 50% 100%, 50% 50%);
}
.ldr-origami-fold span:nth-child(2) {
  --a: 1;
  --p: polygon(50% 100%, 0 50%, 50% 50%);
  --q: polygon(50% 100%, 100% 50%, 50% 50%);
}
.ldr-origami-fold span:nth-child(3) {
  --b: 1;
  --p: polygon(50% 0, 100% 50%, 50% 50%);
  --q: polygon(50% 0, 0 50%, 50% 50%);
}
.ldr-origami-fold span:nth-child(4) {
  --a: 1;
  --b: 1;
  --p: polygon(50% 0, 50% 50%, 0 50%);
  --q: polygon(50% 0, 50% 50%, 100% 50%);
}
.ldr-origami-fold span:nth-child(1)::before {
  background: color-mix(in srgb, var(--c) 66%, #000);
}
.ldr-origami-fold span:nth-child(2)::before,
.ldr-origami-fold span:nth-child(3)::before {
  background: color-mix(in srgb, var(--c) 82%, #000);
}
@keyframes ldr-origami-fold-fold {
  0%, 8%   { transform: rotateY(0deg) rotateX(0deg); }
  28%, 40% { transform: rotateY(calc(var(--a) * 180deg)) rotateX(0deg); }
  56%      { transform: rotateY(0deg) rotateX(0deg); }
  76%, 88% { transform: rotateY(0deg) rotateX(calc(var(--b) * -180deg)); }
  100%     { transform: rotateY(0deg) rotateX(0deg); }
}

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