AI CSS Animations

Spoiler Blur Text Hover

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.

The butler did it

HTML

<div class="hfx-text-spoiler"><span>The butler did it</span></div>

CSS

.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;
  }
}

Tailwind CSS version

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>

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hover effects