AI CSS Animations

Split Square Loader

A square cut on its diagonal slides apart along the cut, turns a quarter while open, then snaps shut. Four quarter turns make one loop; the halves are two clip-path triangles on one box.

Also known as: diagonal split loader, sliding triangles loader, slice square animation.

HTML

<div class="ldr-split-square" role="status" aria-label="Loading"><span></span><span></span></div>

CSS

.ldr-split-square {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: calc(var(--s) * 0.66);
  height: calc(var(--s) * 0.66);
  margin: calc(var(--s) * 0.17);
  animation: ldr-split-square-turn 3.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.ldr-split-square span {
  --k: 1;
  position: absolute;
  inset: 0;
  background: var(--c);
  clip-path: polygon(0 0, 100% 0, 0 100%);
  animation: ldr-split-square-slide 0.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.ldr-split-square span:nth-child(2) {
  --k: -1;
  background: color-mix(in srgb, var(--c) 58%, #fff);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
@keyframes ldr-split-square-slide {
  0%, 100% { transform: translate(0, 0); }
  30%, 70% { transform: translate(calc(var(--k) * var(--s) * 0.1), calc(var(--k) * var(--s) * -0.16)); }
}
@keyframes ldr-split-square-turn {
  0%, 7.5%     { transform: rotate(0deg); }
  17.5%, 32.5% { transform: rotate(90deg); }
  42.5%, 57.5% { transform: rotate(180deg); }
  67.5%, 82.5% { transform: rotate(270deg); }
  92.5%, 100%  { transform: rotate(360deg); }
}

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