Updated
Scroll to Highlight
Customize
Scroll1.6s
Dim0.20
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/scroll-highlight.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/scroll-highlight/scroll-highlight.tsx"use client"; import { cn } from "@/lib/utils"; import { animate, motion, useScroll, useTransform, type MotionValue } from "motion/react"; import { useEffect, useRef } from "react"; // `play` counts presses of a card's Change button. 0 means the card has not // been pressed yet, so every effect renders its resting state without // animating on page load. export type EffectProps = { play: number }; // Size comes from --text-effect-size (default 1.25rem, i.e. text-xl), so a // preview can enlarge every effect without changing the installed default. const SIZE = "text-[length:var(--text-effect-size,1.25rem)] leading-[1.4]"; const TEXT = `${SIZE} text-zinc-700 font-medium dark:text-zinc-200`; // Two mask layers: the vertical fade covers the text column only, and a // solid strip the width of .scrollbar-soft's gutter keeps the scrollbar // fully visible along the right edge. const SCROLLBAR_GUTTER = 12; const SCROLL_MASK = [ `linear-gradient(transparent, black 25%, black 75%, transparent) left / calc(100% - ${SCROLLBAR_GUTTER}px) 100% no-repeat`, `linear-gradient(black, black) right / ${SCROLLBAR_GUTTER}px 100% no-repeat`,
Adds the files to
components/uibrik/scroll-highlight and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/scroll-highlight.Usage
import { ScrollHighlight } from "@/components/uibrik/scroll-highlight/scroll-highlight";const text = "Scroll slowly. Each word waits in the dark until you reach it, then steps into the light.";<ScrollHighlight play={0} text={text} scrollDuration={1.6} dim={0.2}/>Where to use Scroll to Highlight
Storytelling landing pages
Words lighting up as you scroll past them pace a long statement.
Mission and manifesto sections
Reading progress becomes visible as each word lights.
About pages
Scroll-driven emphasis keeps readers moving through a paragraph.
Pairs with Highlighter
Props
ScrollHighlight- text
- Type string
- "Scroll slowly. Each word waits in the dark until you reach it, then steps into the light."
- The copy to animate.
- scrollDuration
- Type number
- 1.6
- Replay scroll-through time.
- dim
- Type number
- 0.2
- Opacity of words not yet reached.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.