Back to library
INTERACTION_166

Text Based Loader.

Words cycle in a fixed slot while assets load. The first word visible before the trigger; cycling words every 320ms with a short lift, then fading the overlay once page load until assets are ready.

CATEGORY
Transitions
COMPLEXITY
Easy
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
LOADINGVAULT
CSS / CSS
/* Text Based Loader — Words cycle in a fixed slot while assets load. */
.text-based-loader {
  --dur: 320ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

.text-based-loader > * {
  opacity: 0;
  transform: translateY(14px);
  animation: text-based-loader-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* the first word visible -> cycling words every 320ms with a short lift, then fading the overlay */
@keyframes text-based-loader-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .text-based-loader > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Text Based Loader — trigger: page load until assets are ready */
export function TextBasedLoader({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
      el.dataset["state"] = "in";
      return;
    }
    const io = new IntersectionObserver(
      ([entry]) => {
        if (entry?.isIntersecting) {
          el.dataset["state"] = "in";
          io.unobserve(el);
        }
      },
      { threshold: 0.2 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  return (
    <div ref={ref} className="text-based-loader" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_167CSS

Progress Bar Loader

A thin top rule tracks navigation progress.

Transitions / LightView
INTERACTION_160CSS

Blur Transition

The outgoing page blurs out and the next resolves into focus.

Transitions / MediumView
Next route/WORK
INTERACTION_161CSS

Slide Transition

Routes slide horizontally in the direction of travel.

Transitions / LightView
INTERACTION_168CSS

Route Change Fade

The quietest option: a short lift and fade between routes.

Transitions / LightView