AI CSS Animations

Outline to Fill Text

Hollow, stroked letters slowly fill with color and empty again. Uses text-stroke for the outline and animates the fill color, so it works with any font.

Also known as: text stroke animation, hollow text fill, outlined text.

HOLLOW

HTML

<div class="txt-outline-fill">HOLLOW</div>

CSS

.txt-outline-fill {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: transparent;
  letter-spacing: 0.06em;
  -webkit-text-stroke: 0.04em var(--c);
  paint-order: stroke fill;
  animation: txt-outline-fill-pulse 2.4s ease-in-out infinite alternate;}
@keyframes txt-outline-fill-pulse {
  to { color: var(--c); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-outline-fill, .txt-outline-fill *, .txt-outline-fill::before, .txt-outline-fill::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • 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 text animations