A spoiler tag: the words sit blurred inside a tinted pill until hovered, then come into focus as the pill fades away. A filter blur in em units keeps the smear in proportion at any size.
Also known as: blur text reveal on hover, hidden spoiler text, unblur on hover.
<div class="hfx-text-spoiler"><span>The butler did it</span></div>
.hfx-text-spoiler {
--c: var(--hfx-color, #3b82f6);
font-size: calc(var(--hfx-size, 16px) * 1.9);
font-family: system-ui, sans-serif;
font-weight: 800;
line-height: 1.15;
cursor: default;
display: inline-block;
padding: 0.1em 0.35em;
border-radius: 0.25em;
background: color-mix(in srgb, var(--c) 15%, transparent);
transition: background-color 0.4s ease;}
.hfx-text-spoiler span {
display: inline-block;
filter: blur(0.16em);
opacity: 0.85;
transition: filter 0.4s ease, opacity 0.4s ease;
}
.hfx-text-spoiler:hover { background-color: transparent; }
.hfx-text-spoiler:hover span {
filter: blur(0);
opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
.hfx-text-spoiler, .hfx-text-spoiler *, .hfx-text-spoiler::before, .hfx-text-spoiler::after, .hfx-text-spoiler *::before, .hfx-text-spoiler *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<span class="group inline-block rounded-md bg-blue-500/15 px-3 py-1 text-3xl font-extrabold transition-colors duration-300 hover:bg-transparent"> <span class="inline-block blur-sm transition duration-300 group-hover:blur-0">The butler did it</span> </span>
--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.