Sonu kumar

Animated Pointer Highlight

Text

About

This code implements a reusable React component called `PointerHighlight` that adds an animated highlight effect to any element. It solves the problem of visually emphasizing interactive elements, improving user experience and engagement. The component works by using the `useRef` and `useEffect` hooks to track the dimensions of the target element and trigger animations when it's in the viewport. `useInView` from `motion/react` detects when the element is visible. A `ResizeObserver` ensures accurate dimensions even after resizing. The `getVariantStyles` function dynamically applies different visual styles based on the selected variant ('default', 'gradient', 'neon', 'minimal', 'premium'). Each variant features unique animations, including border expansion, corner accents, glow effects, and a pointer with a trail effect. The `motion` library from Framer Motion handles the animations, providing smooth transitions and easing functions. The component uses Tailwind CSS for styling and `cn` for efficient class name concatenation. Example scenarios include highlighting interactive elements in dashboards, cards, buttons, and other UI components to guide user interaction and create a more engaging interface. Developers can customize the appearance using props like `variant`, `glowEffect`, and `animationDelay`. The component also handles responsiveness by adapting to changes in element dimensions.

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

Code

How Animated Pointer Highlight is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { PointerHighlight } from "@/components/ui/animated-pointer-highlight";

export default function DemoOne() {
  return (
    <div className="mx-auto max-w-lg py-20 text-2xl font-bold tracking-tight md:text-4xl">
      The best way to grow is to
      <PointerHighlight>
        <span className="px-2">Get viral</span>
      </PointerHighlight>
    </div>
  );
}

Dependencies

More by Sonu kumar

View all
  • Dashboard with Collapsible Sidebar

    Dashboard with Collapsible Sidebar

    2.4K
  • Modern Hero

    Modern Hero

    1.4K
  • Text Parallax Content (scroll)

    Text Parallax Content (scroll)

    1.2K
  • About Us section

    About Us section

    1.2K
  • Modern Animated Hero Section

    Modern Animated Hero Section

    1.1K
  • Animated Hero Section

    Animated Hero Section

    689
  • Cuisine Selector Chips

    Cuisine Selector Chips

    585
  • Bounce card features

    Bounce card features

    573

More in Text

View all
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    103
  • Motion Blur Text

    Motion Blur Text

    36
  • NeonRGBTextEffect

    NeonRGBTextEffect

    144
  • Text Reveal

    Text Reveal

    27
  • Random Letter Swap

    Random Letter Swap

    46
  • Rainbow Text Effect

    Rainbow Text Effect

    47
  • Blur Reveal

    Blur Reveal

    300
  • Text Color

    Text Color

    545