Updated
Highlighter
Read the part that matters.
Customize
Duration0.50s
Color
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/highlighter.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/highlighter/highlighter.tsx"use client"; import { cn } from "@/lib/utils"; import { motion } from "motion/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`; // 16 — A marker sweeps behind the phrase that matters, left to right, with a // slightly uneven edge so it reads as a hand, not a text selection. export function Highlighter({ play, text = "Read the", highlight = "part that matters", duration = 0.5, color = "",
Adds the files to
components/uibrik/highlighter and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/highlighter.Usage
import { Highlighter } from "@/components/uibrik/highlighter/highlighter";<Highlighter play={0} text="Read the" highlight="part that matters" duration={0.5} color=""/>Where to use Highlighter
Key phrases in headlines
A marker sweeping across two or three words tells visitors what matters most.
Blog posts and docs
Highlighting a term as it scrolls into view guides readers to the main point.
Pairs with Scroll to Highlight
Pricing callouts
Marking "free for 14 days" or a discount draws the eye without a badge.
Props
Highlighter- text
- Type string
- "Read the"
- Text before the highlighted phrase.
- highlight
- Type string
- "part that matters"
- The phrase the marker sweeps behind.
- duration
- Type number
- 0.5
- Time for the marker to sweep across.
- color
- Type string
- ""
- Marker colour. Empty follows the theme.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.