AI CSS Animations

Shimmer Text

A bright band sweeps across otherwise muted text, like light on brushed metal. The same idea AI chat apps use for their 'Thinking' status line.

Also known as: shine text, metallic text sweep, text highlight sweep.

Shimmering

HTML

<div class="txt-shimmer">Shimmering</div>

CSS

.txt-shimmer {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 45%, transparent) 0%, var(--c) 50%, color-mix(in srgb, var(--c) 45%, transparent) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: txt-shimmer-sweep 2s linear infinite;}
@keyframes txt-shimmer-sweep {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

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