React + MotionOverlays
Delayed tooltip
A small label that fades in above an icon after a short pause, so it only shows when you really hover.
Settings
450ms
Code
import { useEffect, useRef, useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { X } from "lucide-react";
interface DelayedTooltipProps {
text?: string;
delay?: number;
}
export default function DelayedTooltip({
text = "Close window",
delay = 450,
}: DelayedTooltipProps) {
const [show, setShow] = useState(false);
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
useEffect(() => () => clearTimeout(timer.current), []);
return (
<div
className="relative text-[#1d1d1f] dark:text-[#f5f5f7]"
onMouseEnter={() => {
clearTimeout(timer.current);
timer.current = setTimeout(() => setShow(true), delay);
}}
onMouseLeave={() => {
clearTimeout(timer.current);
setShow(false);
}}
>
<button
type="button"
aria-label={text}
className="grid h-11 w-11 place-items-center rounded-full bg-white dark:bg-[#1c1c1e] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)]"
>
<X className="h-4 w-4" />
</button>
<AnimatePresence>
{show && (
<motion.span
initial={{ opacity: 0, y: 5, scale: 0.96 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 4 }}
className="absolute bottom-14 left-1/2 w-max -translate-x-1/2 rounded-full bg-[#1d1d1f] px-3 py-1.5 text-xs text-[#f5f5f7] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)] dark:bg-[#f5f5f7] dark:text-black"
>
{text}
</motion.span>
)}
</AnimatePresence>
</div>
);
}
Prompt for AI
Paste it into ChatGPT, Claude or Cursor and it will adapt the block to your project with these settings, even if you don’t use React.
More in Overlays
Where to use it
Icon buttons are compact but can be cryptic, and a tooltip says what they do. The delay is the clever part: sweeping the mouse across a toolbar no longer sets off a flicker of labels. Use this React tooltip with a hover delay on a text editor, a video player or the actions of an admin table.
Around 400 to 500 milliseconds feels natural; much longer and people think it is broken. It shows on hover, so also show it on keyboard focus if your users navigate with Tab. Keep the text to a few words.