Back to library
INTERACTION_066

Animated Headline Underline.

A precise 2px rule draws itself under the headline. Scaled to 0 on the X axis with origin left before the trigger; scaling the rule to full width once entry into view.

CATEGORY
Headlines
COMPLEXITY
Easy
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
HEADLINE
CSS / CSS
/* Animated Headline Underline — A precise 2px rule draws itself under the headline. */
.animated-headline-underline {
  --dur: 520ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

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

/* scaled to 0 on the X axis with origin left -> scaling the rule to full width */
@keyframes animated-headline-underline-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Animated Headline Underline — trigger: entry into view */
export function AnimatedHeadlineUnderline({ 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="animated-headline-underline" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

SHIPFASTER
INTERACTION_071CSS

Headline Zoom Transition

The headline scales up slightly as the section takes focus.

Headlines / LightView
SPLIT LINE
HERO REVEAL.
INTERACTION_063CSS

Split Line Hero Reveal

The hero headline arrives line by line from behind its own masks.

Headlines / LightView
SHIPFASTER
INTERACTION_064CSS + JS

Pinned Headline Transformation

A pinned headline changes scale and wording as the section scrolls.

Headlines / MediumView
BUILT FOR
FOUNDERSDESIGNERS
INTERACTION_067CSS

Changing Emphasis Word

The emphasised word cycles through audiences or outcomes.

Headlines / LightView