import { useEffect, useRef, useState } from "react"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; interface Props { children: React.ReactNode; className?: string; } const OverflowTip = ({ children, className }: Props) => { const [isOverflowed, setIsOverflow] = useState(false); const textElementRef = useRef(null); useEffect(() => { if (!textElementRef.current) { return; } setIsOverflow(textElementRef.current.scrollWidth > textElementRef.current.clientWidth); }, []); return (
{children}
{isOverflowed && (

{children}

)}
); }; export default OverflowTip;