AI CSS Animations

Light Sweep Text Reveal

A band of light crosses the empty line and leaves the text lit behind it. One gradient clipped to the text: solid, a pale highlight, then transparent, moved with background-position.

Also known as: shine reveal text, light beam text reveal, glint reveal css.

First light

HTML

<div class="txt-light-sweep-reveal">First light</div>

CSS

.txt-light-sweep-reveal {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: inline-block;
  padding: 0 0.1em;
  white-space: nowrap;
  color: transparent;
  /* solid, a pale band of light, then clear; the gradient is 2.5x the text width */
  background: linear-gradient(100deg, var(--c) 40%, color-mix(in srgb, var(--c) 40%, #fff) 47%, color-mix(in srgb, var(--c) 20%, #fff) 51%, transparent 60%) 100% 0 / 250% 100% no-repeat;
  -webkit-background-clip: text;
          background-clip: text;
  animation: txt-light-sweep-reveal-sweep 1.4s cubic-bezier(0.35, 0, 0.25, 1) forwards;}
@keyframes txt-light-sweep-reveal-sweep {
  to { background-position: 0 0; }
}

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