Types a claim, pauses, strikes through the wrong word and types the right one after it, a copywriting move for hero lines. The strike is a scaled line; the retyped word picks up the accent.
Also known as: typing with strikethrough, cross out and retype text, typed correction effect.
<div class="txt-strikethrough-typing" aria-label="Design is quiet."> <span class="txt-strikethrough-typing-t" aria-hidden="true"><span style="--i: 0">D</span><span style="--i: 1">e</span><span style="--i: 2">s</span><span style="--i: 3">i</span><span style="--i: 4">g</span><span style="--i: 5">n</span><span style="--i: 6"> </span><span style="--i: 7">i</span><span style="--i: 8">s</span><span style="--i: 9"> </span><span class="txt-strikethrough-typing-old"><span style="--i: 10">l</span><span style="--i: 11">o</span><span style="--i: 12">u</span><span style="--i: 13">d</span></span><span class="txt-strikethrough-typing-new"><span style="--i: 14"> </span><span style="--i: 15">q</span><span style="--i: 16">u</span><span style="--i: 17">i</span><span style="--i: 18">e</span><span style="--i: 19">t</span><span style="--i: 20">.</span></span></span> </div>
.txt-strikethrough-typing {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
white-space: nowrap;}
.txt-strikethrough-typing-t span span,
.txt-strikethrough-typing-t > span:not([class]) {
position: relative;
opacity: 0;
animation: txt-strikethrough-typing-key 0s calc(0.3s + var(--i) * 75ms + var(--x, 0s)) forwards;
}
.txt-strikethrough-typing-t span span::after,
.txt-strikethrough-typing-t > span:not([class])::after {
content: "";
position: absolute;
top: 0.12em;
bottom: 0.05em;
right: -0.05em;
width: 0.06em;
background: var(--c);
opacity: 0;
animation: txt-strikethrough-typing-caret 75ms step-end calc(0.3s + var(--i) * 75ms + var(--x, 0s));
}
/* the caret waits after "loud" while it gets struck out */
.txt-strikethrough-typing-old span:last-child::after {
animation-duration: 0.9s;
}
.txt-strikethrough-typing-new span:last-child::after {
animation: txt-strikethrough-typing-blink 1s step-end calc(0.3s + var(--i) * 75ms + var(--x, 0s)) infinite;
}
.txt-strikethrough-typing-old {
position: relative;
animation: txt-strikethrough-typing-dim 0.3s ease-out 1.75s forwards;
}
.txt-strikethrough-typing-old::before {
content: "";
position: absolute;
left: -0.05em;
right: -0.05em;
top: 55%;
height: 0.08em;
border-radius: 0.04em;
background: currentColor;
transform: scaleX(0);
transform-origin: left;
animation: txt-strikethrough-typing-strike 0.3s cubic-bezier(0.6, 0, 0.3, 1) 1.6s forwards;
}
.txt-strikethrough-typing-new {
--x: 0.8s;
color: var(--c);
}
@keyframes txt-strikethrough-typing-key {
to { opacity: 1; }
}
@keyframes txt-strikethrough-typing-caret {
0%, 100% { opacity: 1; }
}
@keyframes txt-strikethrough-typing-blink {
0% { opacity: 1; }
50% { opacity: 0; }
}
@keyframes txt-strikethrough-typing-strike {
to { transform: scaleX(1); }
}
@keyframes txt-strikethrough-typing-dim {
to { color: color-mix(in srgb, currentColor 45%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
.txt-strikethrough-typing, .txt-strikethrough-typing *, .txt-strikethrough-typing::before, .txt-strikethrough-typing::after, .txt-strikethrough-typing *::before, .txt-strikethrough-typing *::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.