OUTLINE
INTERACTION_072CSS
Gradient Border Text
Outlined type with a light gradient travelling around the stroke.
Headlines / LightView
One phrase blurs and dissolves directly into the next. The first phrase sharp, the second blurred at 0 opacity before the trigger; cross-fading with a 8px blur on the outgoing phrase once a 3.2 second interval while in view.
/* Text Morphing — One phrase blurs and dissolves directly into the next. */
.text-morphing {
--dur: 700ms;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
--stagger: 60ms;
will-change: transform, opacity;
}
.text-morphing > * {
opacity: 0;
transform: translateY(14px);
animation: text-morphing-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* the first phrase sharp, the second blurred at 0 opacity -> cross-fading with a 8px blur on the outgoing phrase */
@keyframes text-morphing-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.text-morphing > * {
opacity: 1;
transform: none;
animation: none;
}
}import { useEffect, useRef } from "react";
/** Text Morphing — trigger: a 3.2 second interval while in view */
export function TextMorphing({ 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-morphing" data-state="out">
{children}
</div>
);
}Outlined type with a light gradient travelling around the stroke.
One keyword grows and the rest of the line reflows around it.
Oversized type scrolls sideways in a continuous loop.
Giant type drifts slower than the content in front of it.