While hovered, a wave rolls through the word letter by letter and the letters take the accent color. One keyframe with a rest segment, delayed per letter by its --i index.
Also known as: wave text on hover, letters wave animation, bobbing letters.
<div class="hfx-text-letter-wave" aria-label="Surf's up"><span style="--i: 0">S</span><span style="--i: 1">u</span><span style="--i: 2">r</span><span style="--i: 3">f</span><span style="--i: 4">'</span><span style="--i: 5">s</span><span style="--i: 6"> </span><span style="--i: 7">u</span><span style="--i: 8">p</span></div>
.hfx-text-letter-wave {
--c: var(--hfx-color, #3b82f6);
font-size: calc(var(--hfx-size, 16px) * 2.5);
font-family: system-ui, sans-serif;
font-weight: 800;
line-height: 1.15;
cursor: default;
display: inline-flex;}
.hfx-text-letter-wave span {
display: block;
transition: color 0.3s ease;
transition-delay: calc(var(--i) * 0.04s);
}
.hfx-text-letter-wave:hover span {
color: var(--c);
animation: hfx-text-letter-wave-bob 1.1s ease-in-out infinite;
animation-delay: calc(var(--i) * 0.08s);
}
@keyframes hfx-text-letter-wave-bob {
0%, 60%, 100% { transform: translateY(0); }
30% { transform: translateY(-0.28em); }
}
@media (prefers-reduced-motion: reduce) {
.hfx-text-letter-wave, .hfx-text-letter-wave *, .hfx-text-letter-wave::before, .hfx-text-letter-wave::after, .hfx-text-letter-wave *::before, .hfx-text-letter-wave *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.