The letters drift apart from the center on hover, like widening the tracking. Each span moves by its distance from the middle, so the width never changes and nothing around it reflows.
Also known as: tracking expand on hover, letter spacing animation, text spread hover.
<div class="hfx-text-spread-letters" aria-label="Space"><span style="--i: 0">S</span><span style="--i: 1">P</span><span style="--i: 2">A</span><span style="--i: 3">C</span><span style="--i: 4">E</span></div>
.hfx-text-spread-letters {
--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;
--n: 5; /* number of letters */
display: inline-flex;
font-weight: 700;}
.hfx-text-spread-letters span {
display: block;
transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), color 0.5s ease;
}
.hfx-text-spread-letters:hover span {
color: var(--c);
transform: translateX(calc((var(--i) - (var(--n) - 1) / 2) * 0.18em));
}
@media (prefers-reduced-motion: reduce) {
.hfx-text-spread-letters, .hfx-text-spread-letters *, .hfx-text-spread-letters::before, .hfx-text-spread-letters::after, .hfx-text-spread-letters *::before, .hfx-text-spread-letters *::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.