AI CSS Animations

Glowing Underline Animation

A glowing comet runs along a faint underline and trails off, over and over, for launch and coming soon lines. The comet is a gradient tile on a pseudo-element with a drop-shadow glow.

Also known as: comet underline css, light running along underline, animated underline glow.

Coming soon

HTML

<div class="txt-glowing-underline-text">Coming soon</div>

CSS

.txt-glowing-underline-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;
  position: relative;
  display: inline-block;
  padding-bottom: 0.28em;
  white-space: nowrap;}
.txt-glowing-underline-text::before,
.txt-glowing-underline-text::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 1em;
}
.txt-glowing-underline-text::before {
  bottom: 0.06em;
  height: 0.05em;
  background: color-mix(in srgb, var(--c) 25%, transparent);
}
.txt-glowing-underline-text::after {
  bottom: 0.04em;
  height: 0.09em;
  background: linear-gradient(90deg, transparent, var(--c) 85%, color-mix(in srgb, var(--c) 35%, #fff)) no-repeat;
  background-size: 40% 100%;
  filter: drop-shadow(0 0 0.12em var(--c));
  animation: txt-glowing-underline-text-run 2.2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
/* -70% and 170% park the 40% tile just outside each end */
@keyframes txt-glowing-underline-text-run {
  from { background-position: -70% 0; }
  to   { background-position: 170% 0; }
}

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