GlowText
Animated shine overlay for text and compact UI surfaces.
adaptiveis enabled by default (container-level shimmer, good for images/cards); for text usemode="text-clip"so shimmer clips to glyphs.
text-clipcurrently sweeps right → left (aligned with the ShinyText reference).
Usage
GlowText
Loading demo...
Best Practices
- Use
text-clipfor labels, headings, and gradient text; useadaptivefor image thumbnails, cards, and status chips. - Keep
bandSizebetween24and40for readable text. Larger bands work better on image/card surfaces. - Prefer a light
colorwith moderateopacityon dark surfaces; on light cards, loweropacityor useblendMode="soft-light". - Avoid wrapping focusable controls unless the glow is purely decorative and does not obscure focus rings.
- Do not use
GlowTextas a loading skeleton. UseTxSkeleton,TxProgressBar, orTxLoadingStatefor loading feedback.
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
tag | string | span | Root element used to wrap the default slot. |
active | boolean | true | Disables the shine overlay when set to false. |
repeat | boolean | true | Runs the sweep once when set to false. |
durationMs | number | 2000 | Sweep animation duration in milliseconds. |
delayMs | number | 0 | Delay before the sweep animation starts. |
angle | number | 20 | Band tilt from vertical, in degrees; 0 is an upright band, positive values lean it like /. |
bandSize | number | 38 | Highlight band width as a percentage of the element's width. |
color | string | rgba(255, 255, 255, 0.9) | Highlight color used in the sweep gradient. |
opacity | number | 0.75 | Overlay opacity during the visible part of the sweep. |
blendMode | string | - | Optional CSS mix-blend-mode override for the shine overlay. |
mode | 'classic' | 'adaptive' | 'text-clip' | adaptive | classic uses a plain overlay, adaptive adds blend/backdrop defaults for surfaces, and text-clip mirrors slot text so the shine is clipped to glyphs. |
backdrop | string | - | Optional CSS backdrop filter override for the shine overlay. |
radius | number | 10 | Root border radius in pixels. |
Slots
| Name | Props | Description |
|---|---|---|
default | - | Text or compact content that receives the shine overlay. In text-clip mode, plain text is mirrored into an aria-hidden shine layer. |
Events
TxGlowText does not emit events.
Applied to Images/Cards
GlowText on image
Loading demo...
More Examples
GlowText in UI
Loading demo...
Overview
- The root element is controlled by
tag; keep it inline (span) for text and block (div) for cards, images, or badges. active=falseremoves the shine layer visually but keeps slot content rendered.repeat=falseruns the animation once and keeps the final frame; combine it withdelayMsfor one-shot announcement badges.mode="adaptive"blends withscreen(plus-lighterwhere supported), which is lighten-only. On a light surface a lightcolortherefore changes nothing at all — the component renders, animates, and stays invisible, with no error to go on. Adaptive is for dark cards, images and thumbnails; text on a light page wantstext-clip, and a light card wantsblendMode="soft-light"with a darkercolor.mode="text-clip"reads the rendered slot text after mount and on text mutations; it is best for simple text nodes, not large nested interactive content.- Both sweeps draw the same band.
angletilts it away from vertical andbandSizeis a share of the element's width; the band enters centred half an element before the left edge and leaves half an element past the right. Inadaptivemode the backdrop filter is masked to the band, so only what the band crosses is lifted. - The band travels at a constant speed and then waits off-stage: both sweeps are
linearand finish their travel at 65% of the cycle, holding still for the rest. Easing the travel instead made the band decelerate just before it left and then restart instantly, which reads as a hesitation rather than a pass.--tx-glow-easestill overrides it. opacityholds for the whole travel rather than fading in and out along it. Both endpoints already sit outside the root, which isoverflow: hidden, so there is nothing to fade — the old mid-travel fade dissolved the band while it was still over the element and it never appeared to leave. Opacity only hides the layer during the off-stage hold.- Reduced-motion users get a static highlight because the component disables sweep animation under
prefers-reduced-motion: reduce.
Technologies
- Accessibility note: Both shine layers are
aria-hidden; intext-clipmode the mirrored text is decorative, so keep the real readable text in the default slot. - Band geometry:
angleused to be the gradient's own direction, so the default 20° laid the band nearly flat — thicker than a short card is tall — and a pass washed the whole card light grey instead of crossing it. The adaptive layer was also unmasked: its backdrop filter brightened a strip three element-widths wide, whose edge crossed the element as a hard vertical seam. - Verified coverage:
glow-text.test.tsverifies default adaptive rendering,aria-hiddenshine layers, custom root tags and CSS variables, inactive/one-shot classes, text-clip mirror text, and cleanup when switching back to adaptive mode. - Component source:
packages/tuffex/packages/components/src/glow-text/src/TxGlowText.vue. - Types:
packages/tuffex/packages/components/src/glow-text/src/types.tsexportsGlowTextProps. - Export alias:
packages/tuffex/packages/components/src/glow-text/index.tsexportsGlowText,TxGlowText,GlowTextProps, andTxGlowTextInstance. - Coverage:
packages/tuffex/packages/components/src/glow-text/__tests__/glow-text.test.tsverifies adaptive defaults, CSS variable mapping, state classes,aria-hiddenshine layers, and text-clip mode transitions.
查看源码
packages/tuffex/packages/components/src/glow-text/index.ts