Black bars swipe across the sensitive words like a censor's marker, hold, then lift off to the right. The bars are currentColor, so they are black on light pages and white on dark ones.
Also known as: censored text animation, blacked out text css, classified document text.
<div class="txt-redacted-text">Meet <span style="--i: 0">Ana</span> at <span style="--i: 1">Pier 9</span></div>
.txt-redacted-text {
--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-redacted-text span {
position: relative;
}
.txt-redacted-text span::after {
content: "";
position: absolute;
inset: 0.12em -0.08em 0.04em;
border-radius: 0.05em;
background: currentColor;
transform: scaleX(0);
transform-origin: 0 50%;
animation: txt-redacted-text-bar 4.4s cubic-bezier(0.7, 0, 0.3, 1) infinite;
animation-delay: calc(var(--i) * 0.3s);
}
@keyframes txt-redacted-text-bar {
0% { transform: scaleX(0); transform-origin: 0 50%; }
10%, 58% { transform: scaleX(1); transform-origin: 0 50%; }
59% { transform: scaleX(1); transform-origin: 100% 50%; }
70%, 100% { transform: scaleX(0); transform-origin: 100% 50%; }
}
@media (prefers-reduced-motion: reduce) {
.txt-redacted-text, .txt-redacted-text *, .txt-redacted-text::before, .txt-redacted-text::after, .txt-redacted-text *::before, .txt-redacted-text *::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.