A real text-decoration underline rises into place with a little bounce and thickens as it lands. Because it is the native underline, it follows the text across line breaks and skips descenders.
Also known as: text-underline-offset animation, animated text decoration, multi line underline animation.
<div class="txt-text-decoration-underline">Real underlines wrap across lines</div>
.txt-text-decoration-underline {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
max-width: 9.5em;
text-align: center;
text-decoration-line: underline;
text-decoration-color: transparent;
text-decoration-thickness: 0.02em;
text-underline-offset: 0.6em;
animation: txt-text-decoration-underline-rise 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;}
@keyframes txt-text-decoration-underline-rise {
to {
text-decoration-color: var(--c);
text-decoration-thickness: 0.08em;
text-underline-offset: 0.12em;
}
}
@media (prefers-reduced-motion: reduce) {
.txt-text-decoration-underline, .txt-text-decoration-underline *, .txt-text-decoration-underline::before, .txt-text-decoration-underline::after, .txt-text-decoration-underline *::before, .txt-text-decoration-underline *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.