Back to library
INTERACTION_072

Gradient Border Text.

Outlined type with a light gradient travelling around the stroke. A static low-contrast stroke before the trigger; moving the gradient across the stroke fill once in view, looping every 5 seconds.

CATEGORY
Headlines
COMPLEXITY
Intermediate
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
OUTLINE
CSS / CSS
/* Gradient Border Text — Outlined type with a light gradient travelling around the stroke. */
.gradient-border-text {
  --dur: 5s;
  --ease: linear;
  --stagger: 60ms;
  will-change: transform, opacity;
}

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

/* a static low-contrast stroke -> moving the gradient across the stroke fill */
@keyframes gradient-border-text-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Gradient Border Text — trigger: in view, looping every 5 seconds */
export function GradientBorderText({ 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="gradient-border-text" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

BUILT FOR
FOUNDERSDESIGNERS
INTERACTION_069CSS

Text Morphing

One phrase blurs and dissolves directly into the next.

Headlines / MediumView
SHIPFASTER
INTERACTION_065CSS

Expanding Keyword

One keyword grows and the rest of the line reflows around it.

Headlines / LightView
PREMIUM MOTION —PREMIUM MOTION —PREMIUM MOTION —PREMIUM MOTION —
INTERACTION_068CSS

Horizontal Text Marquee

Oversized type scrolls sideways in a continuous loop.

Headlines / LightView
PREMIUM MOTION —PREMIUM MOTION —PREMIUM MOTION —PREMIUM MOTION —
INTERACTION_070CSS

Oversized Typography Parallax

Giant type drifts slower than the content in front of it.

Headlines / LightView