AI CSS Animations

Hourglass Loader

Two triangles form an hourglass that pauses, then flips with a quick spin. The pause is what sells it, so keep the timing if you retint it.

HTML

<div class="ldr-hourglass" role="status" aria-label="Loading"></div>

CSS

.ldr-hourglass {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  box-sizing: content-box;
  width: 0;
  height: 0;
  border: calc(var(--s) / 2) solid var(--c);
  border-color: var(--c) transparent var(--c) transparent;
  border-radius: 50%;
  animation: ldr-hourglass-flip 1.4s infinite;
}
@keyframes ldr-hourglass-flip {
  0%   { transform: rotate(0deg);    animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19); }
  50%  { transform: rotate(900deg);  animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  100% { transform: rotate(1800deg); }
}

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