# Animated Pointer Highlight

> 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.

- Author: [Sonu](https://21st.dev/@uniquesonu)
- License: unknown
- npm dependencies: motion
- Live preview: https://21st.dev/@uniquesonu/components/animated-pointer-highlight

## Install

```bash
npx shadcn@latest add "https://21st.dev/r/uniquesonu/animated-pointer-highlight?api_key=$API_KEY_21ST"
```

Requires a 21st API key (generate one at https://21st.dev/mcp) passed as `API_KEY_21ST`. Free accounts get a limited number of installs per day; unlimited on a paid plan — see https://21st.dev/pricing.

Full component directory: https://21st.dev/llms.txt
