GlowText
An animated highlight band that sweeps across text or content.
Usage
Text
mode="text-clip" clips the highlight to the glyphs, gradient text included.
Loading demo...
Images and Cards
The default adaptive mode sweeps the whole container; set tag="div" around block content.
Loading demo...
UI Elements
:repeat="false" sweeps once; pair it with delayMs for a one-shot feature badge.
Loading demo...
Best Practices
- Use
text-clipfor labels, headings, and gradient text; useadaptivefor images, cards, and status chips. - Keep
bandSizebetween24and40on text; wider bands suit images and cards. - On light cards, lower
opacityor useblendMode="soft-light"with a darkercolor. - Don't wrap focusable controls, so the highlight never hides a focus ring.
- Don't use it as a loading skeleton; use
TxSkeleton,TxProgressBar, orTxLoadingState.
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
tag | string | span | Root element; span for text, div for cards or images. |
active | boolean | true | Shows the sweep; when false, the slot still renders. |
repeat | boolean | true | Loops the sweep; false runs it once. |
durationMs | number | 2000 | Length of one cycle in ms. |
delayMs | number | 0 | Delay before the sweep starts, in ms. |
angle | number | 20 | Band tilt from vertical in degrees; 0 is upright, positive leans like /. |
bandSize | number | 38 | Band width as a percentage of the element's width. |
color | string | rgba(255, 255, 255, 0.9) | Highlight color. |
opacity | number | 0.75 | Highlight opacity. |
blendMode | string | - | Custom mix-blend-mode; adaptive defaults to plus-lighter, else screen. |
mode | 'classic' | 'adaptive' | 'text-clip' | adaptive | classic is a plain overlay, adaptive adds blend and backdrop defaults, text-clip clips to glyphs. |
backdrop | string | - | Custom backdrop-filter, such as brightness(1.2) saturate(1.1). |
radius | number | 10 | Root corner radius in px. |
Slots
| Name | Props | Description |
|---|---|---|
default | - | Content that receives the sweep; in text-clip, plain text is mirrored into an aria-hidden layer. |
Overview
adaptiveonly lightens, so a lightcoloron a light surface stays invisible, with no error.text-clipreads the slot text on mount and on text changes; it suits simple text only.- The band travels at a constant speed from half a width before the left edge to half a width past the right, over 65% of the cycle, then waits off-stage;
--tx-glow-easeoverrides the easing. - In
adaptive, the backdrop filter affects only what the band crosses. - Both shine layers are
aria-hidden; keep the readable text in the default slot. - Under reduced motion the sweep stops and a static, centered highlight remains.
Technologies
- The band is one
linear-gradientat90deg + angleon a layer three element-widths wide, moved bytransform(background-positionintext-clip). - Source:
packages/tuffex/packages/components/src/glow-text/.
查看源码
packages/tuffex/packages/components/src/glow-text/index.ts