Daniel Petho

Text Highlighter

Text 3

About

Animated text highlighter that sweeps a marker-style background behind inline text, triggered on hover, scroll into view, or imperatively via ref, with configurable direction and color.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Text Highlighter to your project and fits it to your theme.

Code

How Text Highlighter is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client"

import { TextHighlighter } from "@/components/ui/text-highlighter"

export default function TextHighlighterHoverDemo() {
  return (
    <div className="w-dvw h-dvh bg-[#fefefe] flex items-center justify-center">
      <div className="max-w-sm md:max-w-md lg:max-w-lg xl:max-w-xl mx-auto px-4 text-black">
        <div className="flex flex-col gap-8 text-lg sm:text-xl md:text-2xl lg:text-3xl text-center">
          <TextHighlighter
            triggerType="hover"
            direction="ltr"
            className="px-2 py-1 cursor-pointer"
            highlightColor="#BBC2E2"
            transition={{ type: "spring", duration: 0.68, bounce: 0 }}
          >
            hover me - left to right
          </TextHighlighter>

          <TextHighlighter
            triggerType="hover"
            direction="rtl"
            className="px-2 py-1 cursor-pointer"
            highlightColor="#BBC2E2"
            transition={{ type: "spring", duration: 0.8, bounce: 0 }}
          >
            hover me - right to left
          </TextHighlighter>

          <TextHighlighter
            triggerType="hover"
            direction="ttb"
            className="px-2 py-1 cursor-pointer"
            highlightColor="#BBC2E2"
            transition={{ type: "spring", duration: 0.8, bounce: 0 }}
          >
            hover me - top to bottom
          </TextHighlighter>

          <TextHighlighter
            triggerType="hover"
            direction="btt"
            className="px-2 py-1 cursor-pointer"
            highlightColor="#BBC2E2"
            transition={{ type: "spring", duration: 0.8, bounce: 0 }}
          >
            hover me - bottom to top
          </TextHighlighter>
        </div>
      </div>
    </div>
  )
}

Dependencies

More by Daniel Petho

View all
  • Parallax Floating

    Parallax Floating

    2.4K
  • Text Rotate

    Text Rotate

    2.2K
  • Typewriter

    Typewriter

    1.9K
  • Marquee Along SVG Path

    Marquee Along SVG Path

    1.5K
  • Image Trail

    Image Trail

    1.4K
  • Animated Gradient With SVG

    Animated Gradient With SVG

    904
  • Text Cursor Proximity

    Text Cursor Proximity

    808
  • Pixel Trail

    Pixel Trail

    659

More in Text

View all
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    134
  • Blur Reveal

    Blur Reveal

    395
  • Reveal Text

    Reveal Text

    165
  • Scroll Fill Headline

    Scroll Fill Headline

    66
  • Astryx Chat Tokenized Text

    Astryx Chat Tokenized Text

    14
  • Text Reveal

    Text Reveal

    405
  • Motion Blur Text

    Motion Blur Text

    48
  • Liquid Text

    Liquid Text

    277