Shimmer

Text with a light band sweeping across it, for "Thinking…". A CSS utility, shimmer, and a component that applies it. No script.

Anatomy

{as}.text-fg-muted.motion-safe:shimmer   ← span by default
└── the slot

as: span, p, div, strong, small, h2, h3, h4, li, dt, dd; anything else renders a span.

The utility

color: transparent;
background-image: linear-gradient(90deg, fg-muted 0 40%, fg 50%, fg-muted 60% 100%);
background-size: 250% 100%;
background-clip: text;              /* and -webkit- */
animation: ds-shimmer-text 2s linear infinite;   /* position 100% → 0 */

The gradient is 2.5 times the box, so at either end of the animation a muted part fills the box and the foreground band crosses in between. Colours are the fg and fg-muted tokens, so it is right in both themes with no dark rule. Right-to-left text runs it in reverse. Under reduced motion the utility does not apply (it is only ever written motion-safe:shimmer) and the text is text-fg-muted, still.

Accessibility

Rolenone: it is the text it wraps
Announcementthe host's: put it inside role="status" rendered before the words
Keyboardnone
Motionmotion-safe: only

The words carry the state; the band is decoration.

Do not

  • Do not shimmer content. Only a short label about the wait.
  • Do not rely on it to announce anything. It does not.
  • Do not put links or coloured text inside. The text colour is painted over.

From the package repo: edit this page on GitHub.

Was this page helpful?