Baktiyar Ablaikhan

Pointer Highlight

Source
Aceternity UI ↗
Author
Aceternity UI
Licence
Aceternity UI licence (free component)

Loading…

A box draws itself around a word while a cursor glides along its corner.

Code

"use client";
import { useEffect, useState } from "react";
import { PointerHighlight } from "@/lab/aceternity/ui/pointer-highlight";

export default function PointerHighlightDemo() {
  // The original plays once when scrolled into view; replay it so the card keeps moving.
  const [run, setRun] = useState(0);
  useEffect(() => {
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
    const id = setInterval(() => setRun((r) => r + 1), 4500);
    return () => clearInterval(id);
  }, []);

  return (
    <div className="@container relative flex h-full w-full items-center justify-center px-6">
      <div className="max-w-[80%] text-[clamp(1.1rem,5cqw,2.5rem)] leading-snug font-bold tracking-tight text-neutral-900 dark:text-neutral-100">
        The best way to grow is to
        <PointerHighlight key={run}>
          <span>collaborate</span>
        </PointerHighlight>
      </div>
    </div>
  );
}
Prompt

Build "Pointer Highlight", a text animation. What it does: A box draws itself around a word while a cursor glides along its corner. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: the Motion library, inline SVG. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://ui.aceternity.com/components/pointer-highlight (Aceternity UI, Aceternity UI licence (free component)).