<section class="demo">
<div class="demo__frame">
<h2 class="demo__title">Design with motion</h2>
<p class="demo__lead">Each word arrives on its own beat.</p>
</div>
</section>.demo {
min-height: 100vh;
display: grid;
place-items: center;
background: #0c0c0e;
color: #f2f2f0;
font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}
.demo__frame {
width: min(920px, 88vw);
text-align: center;
}
.demo__title {
display: flex;
flex-wrap: wrap;
justify-content: center;
column-gap: 0.28em;
row-gap: 0.08em;
margin: 0 auto 18px;
font-size: clamp(44px, 8.4vw, 96px);
font-weight: 600;
letter-spacing: -0.06em;
line-height: 1.02;
}
.demo__title .word {
display: inline-block;
overflow: hidden;
vertical-align: bottom;
padding-bottom: 0.08em;
}
.demo__title .word span {
display: inline-block;
transform: translateY(110%);
will-change: transform;
}
.demo__lead {
margin: 0;
font-size: 15px;
letter-spacing: -0.01em;
color: rgb(242 242 240 / 0.48);
}const title = document.querySelector(".demo__title");
const words = title.textContent.trim().split(/\s+/);
title.innerHTML = words.map(function (word) {
return '<span class="word"><span>' + word + "</span></span>";
}).join(" ");
const chars = title.querySelectorAll(".word span");
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (reduce) {
gsap.set(chars, { y: 0 });
} else {
gsap.fromTo(chars, { y: "110%" }, {
y: "0%",
duration: 0.95,
ease: "power3.out",
stagger: 0.1,
delay: 0.12,
});
}