Back to library
INTERACTION_058

Variable Font Weight Animation.

Weight animates from light to black across the characters. Weight 200 across all characters before the trigger; animating font-variation-settings weight to 800 in a wave once entry into view, or pointer proximity on desktop.

CATEGORY
Letters
COMPLEXITY
Intermediate
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
VAULT
CSS / CSS
/* Variable Font Weight Animation — Weight animates from light to black across the characters. */
.variable-font-weight-animation {
  --dur: 900ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 40ms;
  will-change: transform, opacity;
}

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

/* weight 200 across all characters -> animating font-variation-settings weight to 800 in a wave */
@keyframes variable-font-weight-animation-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Variable Font Weight Animation — trigger: entry into view, or pointer proximity on desktop */
export function VariableFontWeightAnimation({ 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="variable-font-weight-animation" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

VAULT
INTERACTION_050CSS + JS

Scattered Letters Assemble

Characters fly in from random offsets and lock into the word.

Letters / LightView
VAULT
INTERACTION_051CSS

Letter Flip

Characters flip on the X axis like a departure board.

Letters / LightView
VAULT
INTERACTION_053CSS

Vertical Character Roll

Each character rolls up inside its own clipped slot.

Letters / LightView
VAULT
INTERACTION_054CSS + JS

Cursor Reactive Letters

Characters lift and brighten as the pointer passes over them.

Letters / LightView