PeakUIPro

TextShimmer

Animated shimmer text for thinking and loading labels

Usage

import {TextShimmer} from "@peakui-pro/react";

Examples

Color Utility

className colors both layers; raise --text-shimmer-rest for a color dimmer than text-foreground.

Long Text

In Sentence

Custom Spread

--spread sets how far the highlight takes to fade out on each side.

Customization

Tailwind CSS

<TextShimmer className="text-muted [--text-shimmer-rest:90%] [--spread:6ch]">
  Searching the web...
</TextShimmer>

Global CSS

@layer components {
  .text-shimmer {
    --spread: 6ch;
    /* 60% holds 4.5:1 for the default foreground on --background only. */
    --text-shimmer-rest: 70%;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The TextShimmer component uses these CSS classes (view source styles):

Base Classes

  • .text-shimmer - The root; an inline box that takes its color and size from the context

Element Classes

  • .text-shimmer__text - The readable layer, drawn at --text-shimmer-rest of its color
  • .text-shimmer__highlight - An inert copy whose letters mask the sweeping gradient

Slots

  • [data-slot="text-shimmer"] - The root element
  • [data-slot="text-shimmer-text"] - The readable layer
  • [data-slot="text-shimmer-highlight"] - The inert mask copy

CSS Variables

VariablePurpose
--spreadWidth of the highlight falloff on each side of its center; defaults to 4ch
--text-shimmer-restShare of its color the label keeps between sweeps; defaults to 60%

Interactive States

The sweep is the component's only motion, and these conditions remove it:

  • Reduced motion: @media (prefers-reduced-motion: reduce) hides the highlight and draws the text fully opaque
  • Forced colors: @media (forced-colors: active) does the same, so the system palette colors a solid label
  • No mask-clip: text support: @supports not ((mask-clip: text) or (-webkit-mask-clip: text)) shows solid text and no sweep

API Reference

TextShimmer

PropTypeDefaultDescription
childrenReactNode-The label. Rendered twice, the second copy inert and aria-hidden, so an id or an interactive element in it is duplicated
classNamestring-Additional classes, including color and text size utilities. The contrast guarantee of 4.5:1 at the default --text-shimmer-rest covers the default foreground on --background only
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element
...restComponentProps<'span'>-Native <span> attributes

On this page