Highlight Text

A marker stroke that sweeps across text as it scrolls into view.

gsap@gsap/reactMIT · free

Good design is mostly about knowing what to leave out, and great motion is about knowing when to stop.

Installation

npx shadcn@latest add https://ombakui.com/r/highlight-text.json

Usage

import { HighlightText } from "@/components/highlight-text";

<p>
  Good design is about <HighlightText>knowing what to leave out</HighlightText>.
</p>

// follow the scroll position instead of playing once
<HighlightText scrub color="rgba(94, 240, 200, 0.45)">…</HighlightText>

Props

PropTypeDefaultDescription
children*ReactNode–
asElementType"span"HTML tag to render.
colorstring"rgba(250, 204, 21, 0.4)"Marker color. Any CSS color.
scrubbooleanfalseTie the sweep to the scroll position instead of playing once.
durationnumber1.1Seconds for the sweep when not scrubbing.
delaynumber0Seconds before starting.
startstring"top 80%"ScrollTrigger start position.
thicknessnumber0.4How much of the line height the marker covers, 0–1.
classNamestring–