A three-letter acronym unfolds into its full words on hover, the missing letters sliding out from behind each initial. Each tail is a grid track that transitions from 0fr to 1fr.
Also known as: expand text on hover, abbreviation reveal, acronym unfold animation.
<div class="hfx-text-acronym-expand" aria-label="Do it yourself"> <span>D<span class="hfx-text-acronym-expand-tail"><span>o </span></span></span> <span>I<span class="hfx-text-acronym-expand-tail"><span>t </span></span></span> <span>Y<span class="hfx-text-acronym-expand-tail"><span>ourself</span></span></span> </div>
.hfx-text-acronym-expand {
--c: var(--hfx-color, #3b82f6);
font-size: calc(var(--hfx-size, 16px) * 2.2);
font-family: system-ui, sans-serif;
font-weight: 800;
line-height: 1.15;
cursor: default;
display: inline-flex;
font-weight: 900;
letter-spacing: 0.02em;}
.hfx-text-acronym-expand > span {
display: inline-flex;
transition: color 0.4s ease;
}
.hfx-text-acronym-expand-tail {
display: grid;
grid-template-columns: 0fr;
font-weight: 500;
color: var(--c);
opacity: 0;
transition: grid-template-columns 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}
.hfx-text-acronym-expand-tail > span {
min-width: 0;
overflow: hidden;
white-space: nowrap;
}
.hfx-text-acronym-expand > span:nth-child(2) .hfx-text-acronym-expand-tail { transition-delay: 0.05s; }
.hfx-text-acronym-expand > span:nth-child(3) .hfx-text-acronym-expand-tail { transition-delay: 0.1s; }
.hfx-text-acronym-expand:hover .hfx-text-acronym-expand-tail {
grid-template-columns: 1fr;
opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
.hfx-text-acronym-expand, .hfx-text-acronym-expand *, .hfx-text-acronym-expand::before, .hfx-text-acronym-expand::after, .hfx-text-acronym-expand *::before, .hfx-text-acronym-expand *::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.