AI CSS Animations

Full Page Loading Overlay

A translucent, blurred overlay with a spinner and a message, for the moment between a route change and its data. Swap absolute for fixed to cover the whole viewport.

Also known as: page preloader, loading screen, loading modal.

Loading your dashboard…

HTML

<div class="ldr-page-overlay" role="status" aria-live="polite">
  Loading your dashboard…
</div>

CSS

.ldr-page-overlay {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: absolute; /* use fixed to cover the whole viewport */
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--s) / 3);
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  font: 500 calc(var(--s) / 3.5) system-ui, sans-serif;
  color: var(--c);
}
.ldr-page-overlay::before {
  content: "";
  width: var(--s);
  height: var(--s);
  border: calc(var(--s) / 10) solid color-mix(in srgb, var(--ldr-color, #3b82f6) 20%, transparent);
  border-top-color: var(--c);
  border-radius: 50%;
  animation: ldr-page-overlay-spin 0.8s linear infinite;
}
@keyframes ldr-page-overlay-spin {
  to { transform: rotate(360deg); }
}

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