SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

textShimmer

Sweeping highlight through a run of text's own glyphs for a caption that stands in for a busy state.

tsx
import { textShimmer } from "@sdxc/ui/animations";

Usage

Sweeping highlight through a run of text's own glyphs for a caption that stands in for a busy state. The background-clip: text paint sits behind an @supports guard; reduced motion breathes the caption's opacity.

Signature

typescript
textShimmer<Node extends Element = Element>(options?: TextShimmer.Options): Mixin<Node>

Returns a @sdxc/u mixin ready for a caption's host text element.

Parameters

ParameterTypeDefaultRequiredDescription
optionsTextShimmer.Options—NoTiming, band width, angle, color, and gating for the loop.

Examples

tsx
<Text mix={[textShimmer()]}>{t("chat.generating")}</Text>
tsx
<Text mix={[textShimmer({ color: "var(--ui-brand-fg)", duration: "1.5s" })]}>
	{t("chat.generating")}
</Text>

The events, constants and types its module publishes, each imported from @sdxc/ui/animations too.

Interface

TextShimmer.Options

Tuning for a text shimmer loop: timing, the highlight band's width and angle of travel, its color, and the platform state it runs under.

MemberTypeDefaultRequiredDescription
durationstring—NoLength of one sweep across the band, as a CSS time. Defaults to DEFAULT_TEXT_SHIMMER_DURATION.
easingstring—NoCSS easing function driving the sweep. Defaults to DEFAULT_TEXT_SHIMMER_EASING.
bandSizestring—NoWidth of the moving highlight band, as a CSS length or percentage. Defaults to DEFAULT_TEXT_SHIMMER_BAND_SIZE.
anglestring—NoCSS angle the highlight band travels along. Defaults to DEFAULT_TEXT_SHIMMER_ANGLE.
colorstring—NoColor the highlight band peaks at as it passes; the tone the text rests at between passes is this same color mixed toward transparency. Defaults to DEFAULT_TEXT_SHIMMER_COLOR.
whenstring—NoSelector fragment, relative to the host (e.g. [data-streaming="true"]), that gates the loop. Left unset, the loop runs as soon as it is mixed in, matching a caption mounted only while a response streams in.
@sdxc/ui

Can’t find it? Contact us