Components/GlowText

GlowText

An animated highlight band that sweeps across text or content.

VerifiedSince 0.3.4

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-clip for labels, headings, and gradient text; use adaptive for images, cards, and status chips.
  • Keep bandSize between 24 and 40 on text; wider bands suit images and cards.
  • On light cards, lower opacity or use blendMode="soft-light" with a darker color.
  • Don't wrap focusable controls, so the highlight never hides a focus ring.
  • Don't use it as a loading skeleton; use TxSkeleton, TxProgressBar, or TxLoadingState.

API Reference

Props

PropTypeDefaultDescription
tagstringspanRoot element; span for text, div for cards or images.
activebooleantrueShows the sweep; when false, the slot still renders.
repeatbooleantrueLoops the sweep; false runs it once.
durationMsnumber2000Length of one cycle in ms.
delayMsnumber0Delay before the sweep starts, in ms.
anglenumber20Band tilt from vertical in degrees; 0 is upright, positive leans like /.
bandSizenumber38Band width as a percentage of the element's width.
colorstringrgba(255, 255, 255, 0.9)Highlight color.
opacitynumber0.75Highlight opacity.
blendModestring-Custom mix-blend-mode; adaptive defaults to plus-lighter, else screen.
mode'classic' | 'adaptive' | 'text-clip'adaptiveclassic is a plain overlay, adaptive adds blend and backdrop defaults, text-clip clips to glyphs.
backdropstring-Custom backdrop-filter, such as brightness(1.2) saturate(1.1).
radiusnumber10Root corner radius in px.

Slots

NamePropsDescription
default-Content that receives the sweep; in text-clip, plain text is mirrored into an aria-hidden layer.

Overview

  • adaptive only lightens, so a light color on a light surface stays invisible, with no error.
  • text-clip reads 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-ease overrides 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-gradient at 90deg + angle on a layer three element-widths wide, moved by transform (background-position in text-clip).
  • Source: packages/tuffex/packages/components/src/glow-text/.
查看源码
packages/tuffex/packages/components/src/glow-text/index.ts