text animations
Text Highlight
A background colour animates in behind text — triggered by scroll, hover, or imperative ref. Supports four sweep directions and fully customisable colour.
Installation
Usage
Anatomy
Good to know
triggerTypedecides when the highlight draws:"inView"(default),"auto"(on mount),"hover"or"ref".- With
triggerType="ref", callref.current.animate()andref.current.reset()yourself.reset()clears instantly, so you can replay right after it. directionis"ltr","rtl","ttb"or"btt".- Pick a
highlightColorwith enough contrast against the text color in both themes. A translucent colour (alpha around 0.4) works on light and dark backgrounds. - When the user has turned on reduced motion, the highlight appears at full size straight away instead of sweeping in.
Props
Ref API
With triggerType="ref", control the animation imperatively:
Examples
Scroll Triggered
A key phrase in a heading highlights left-to-right when it enters the viewport. once: true means it only plays once.
Hover Triggered
The highlight fills in on mouse enter and vanishes on mouse leave — works well for editorial callouts.
Direction Picker
Buttons call ref.current.animate(direction) to demonstrate all four sweep directions — ltr, rtl, ttb, btt — on demand.