MarqueeText
A clipped single-line label that becomes a hover-triggered marquee when its
text is wider than the clip box, and stays a plain truncated label when it
fits. On overflow it renders a duplicate aria-hidden copy and scrolls the
pair for a seamless loop; a ResizeObserver on both the clip box and the
text node re-measures on resize and on content change, setting
--marquee-duration / --marquee-shift.
Extracted from product-card-category's CategoryLabel.
Usage
Best practices
The scroll is gated on a
.groupancestor's hover (the.animate-marqueeutility runs only under.group:hover, plus adata-play="running"escape hatch) - a loneMarqueeTextwill not animate on its own hover. Wrap it in a.groupelement (typically the hoverable card) to trigger the reveal.It only scrolls when the text overflows; short text that fits stays a static clipped label with no duplicate copy and no animation.
Honours
prefers-reduced-motionautomatically via the shared.animate-marqueeutility, which disables the animation.
Props
Also exports
- interface
MarqueeTextProps
Composition
Builds on
Used by