AI CSS Animations

Flipping Book Loader

An open book whose pages turn from right to left, one after another in a steady rhythm. Pages rotate in 3D around the spine with rotateY, so it needs no images or JavaScript.

Also known as: book page flip animation, reading loader, flipping pages css.

HTML

<div class="ldr-book-pages" role="status" aria-label="Loading">
  <span></span><span></span><span></span>
</div>

CSS

.ldr-book-pages {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  --page: color-mix(in srgb, var(--c) 14%, #fff);
  --lines: repeating-linear-gradient(to bottom, transparent 0 calc(var(--s) * 0.07), color-mix(in srgb, var(--ldr-color, #3b82f6) 45%, transparent) 0 calc(var(--s) * 0.095)) 22% 26% / 62% 56% no-repeat;
  position: relative;
  width: var(--s);
  height: var(--s);
  perspective: calc(var(--s) * 3);
}
.ldr-book-pages::before,
.ldr-book-pages::after {
  content: "";
  position: absolute;
  top: 20%;
  bottom: 20%;
}
.ldr-book-pages::before {
  left: 2%;
  right: 2%;
  border-radius: calc(var(--s) / 14);
  background:
    var(--lines),
    linear-gradient(var(--page) 0 0) calc(var(--s) * 0.04) calc(var(--s) * 0.035) / calc(50% - var(--s) * 0.055) calc(100% - var(--s) * 0.1) no-repeat,
    var(--c);
}
.ldr-book-pages::after {
  left: 50%;
  width: calc(48% - var(--s) * 0.04);
  margin-left: calc(var(--s) * 0.015);
  margin-top: calc(var(--s) * 0.035);
  bottom: calc(20% + var(--s) * 0.065);
  border-radius: 0 calc(var(--s) / 30) calc(var(--s) / 30) 0;
  background: var(--lines), var(--page);
}
.ldr-book-pages span {
  position: absolute;
  z-index: 1;
  left: calc(50% + var(--s) * 0.015);
  top: calc(20% + var(--s) * 0.035);
  bottom: calc(20% + var(--s) * 0.065);
  width: calc(48% - var(--s) * 0.04);
  border-radius: 0 calc(var(--s) / 30) calc(var(--s) / 30) 0;
  background: var(--lines), linear-gradient(90deg, color-mix(in srgb, var(--ldr-color, #3b82f6) 30%, transparent), transparent 45%), var(--page);
  transform-origin: 0 50%;
  animation: ldr-book-pages-turn 1.8s cubic-bezier(0.45, 0.05, 0.35, 1) infinite;
}
.ldr-book-pages span:nth-child(2) { animation-delay: 0.3s; }
.ldr-book-pages span:nth-child(3) { animation-delay: 0.6s; }
@keyframes ldr-book-pages-turn {
  0%        { transform: rotateY(0); }
  50%, 100% { transform: rotateY(-180deg); }
}

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