AI CSS Animations

Text Fill Hover Effect

The accent color wipes across the word from left to right on hover. The fill is a background clipped to the text, so only background-size animates and the glyphs never move.

Also known as: text fill on hover, background clip text hover, color wipe text.

Explore

HTML

<div class="hfx-text-fill-wipe">Explore</div>

CSS

.hfx-text-fill-wipe {
  --c: var(--hfx-color, #3b82f6);
  font-size: calc(var(--hfx-size, 16px) * 2.5);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.15;
  cursor: default;
  display: inline-block;
  -webkit-text-fill-color: transparent;
  background:
    linear-gradient(var(--c), var(--c)) 0 0 / 0% 100% no-repeat,
    linear-gradient(currentColor, currentColor);
  -webkit-background-clip: text;
  background-clip: text;
  transition: background-size 0.55s cubic-bezier(0.65, 0, 0.35, 1);}
.hfx-text-fill-wipe:hover { background-size: 100% 100%, auto; }

@media (prefers-reduced-motion: reduce) {
  .hfx-text-fill-wipe, .hfx-text-fill-wipe *, .hfx-text-fill-wipe::before, .hfx-text-fill-wipe::after, .hfx-text-fill-wipe *::before, .hfx-text-fill-wipe *::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="bg-[linear-gradient(#3b82f6,#3b82f6),linear-gradient(#111827,#111827)] bg-[length:0%_100%,100%_100%] bg-no-repeat bg-clip-text text-5xl font-extrabold text-transparent transition-[background-size] duration-500 hover:bg-[length:100%_100%,100%_100%]">
  Explore
</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