AI CSS Animations

Mesh Gradient Text

Four soft color blobs wander inside the letters and blend like a mesh gradient. Each blob is a radial-gradient layer, and one keyframe moves all four along different paths.

Also known as: blob gradient text, moving mesh gradient css, fluid gradient text.

Mesh Gradient

HTML

<div class="txt-mesh-gradient-text">Mesh Gradient</div>

CSS

.txt-mesh-gradient-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;
  font-weight: 800;
  background:
    radial-gradient(circle closest-side, color-mix(in srgb, var(--c) 20%, #ec4899), transparent) 0% 0% / 65% 250% no-repeat,
    radial-gradient(circle closest-side, color-mix(in srgb, var(--c) 25%, #8b5cf6), transparent) 100% 100% / 60% 250% no-repeat,
    radial-gradient(circle closest-side, color-mix(in srgb, var(--c) 20%, #06b6d4), transparent) 50% 0% / 55% 250% no-repeat,
    radial-gradient(circle closest-side, color-mix(in srgb, var(--c) 25%, #10b981), transparent) 0% 100% / 50% 250% no-repeat,
    var(--c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: txt-mesh-gradient-text-wander 6s ease-in-out infinite;}
@keyframes txt-mesh-gradient-text-wander {
  0%, 100% { background-position: 0% 0%, 100% 100%, 50% 0%, 0% 100%; }
  25%      { background-position: 60% 100%, 30% 0%, 100% 70%, 40% 0%; }
  50%      { background-position: 100% 30%, 0% 60%, 20% 100%, 100% 60%; }
  75%      { background-position: 30% 70%, 70% 20%, 0% 30%, 70% 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .txt-mesh-gradient-text, .txt-mesh-gradient-text *, .txt-mesh-gradient-text::before, .txt-mesh-gradient-text::after, .txt-mesh-gradient-text *::before, .txt-mesh-gradient-text *::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