Skip to content
Sign in
EffectsHighlight sweepMenu

Highlight sweepPro

A marker drawn behind the phrase a citation supports, line by line in reading order.

ProPoint at a citation and the sentence it supports is marked, line by line.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/highlight-sweep

Usage

tsx
import {
  HighlightSweep,
  HighlightSweepGroup,
  useHighlightSweepTrigger,
} from "@/components/ui/chatcn/pro/highlight-sweep"

<HighlightSweepGroup>
  <p>
    Because <HighlightSweep id="a">it has to pull heat out of colder air</HighlightSweep>
    <Citation index={1} source={source} {...useHighlightSweepTrigger("a")} />
  </p>
</HighlightSweepGroup>

A wrapped phrase is several line boxes, so the marker is one rect per line, each revealed with clip-path: inset() from the reading start at one speed: a short last line takes less time than a full one, and each line begins as the one before ends. In right to left text the sweep starts at the right. Turning off fades the marker instead of wiping it back. Use active on its own, or a group with triggers on citations, source rows or HighlightSweepTrigger.

Examples

States

ProTones, underline, a phrase over four lines, reduced motion and triggers.

Props

PropTypeNotes
activebooleanDraw the highlight. Or use id in a group
idstringTies the phrase to triggers in a HighlightSweepGroup
tone"accent" | "amber" | "neutral"Default accent
variant"marker" | "underline"Default marker
speednumberPixels per second. Default 900
reducedMotionbooleanForce it on or off
HighlightSweepGroupvalue, defaultValue, onValueChangeWhich phrase is lit
useHighlightSweepTrigger(id)Pointer and focus props for any element

Accessibility

  • The marker layer is decorative; the phrase and its citation stay plain text and links.
  • Triggers light the phrase on focus as well as on pointer over, so keyboard users get the same link.
  • In forced colors the marker uses the system Highlight color.

Motion

Each line sweeps at constant speed, 90 to 420 ms per line, and the last line eases out. Off is a 150 ms fade. Reduced motion keeps a 150 ms fade and no sweep.