๐จ
UI Library
A collection of beautiful, reusable React components and CSS snippets built with Tailwind CSS and Framer Motion.
Tooltips
Brief, contextual explanations that appear on hover.
Basic Tooltip
More information
Delete permanently
Tooltip.tsxLanguage: tsx
import { useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
export function Tooltip({ children, text }: { children: React.ReactNode, text: string }) {
const [isHovered, setIsHovered] = useState(false);
return (
<div
className="relative flex items-center justify-center"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
{children}
<AnimatePresence>
{isHovered && (
<motion.div
initial={{ opacity: 0, y: 5 }}
animate={{ opacity: 1, y: -5 }}
exit={{ opacity: 0, scale: 0.95 }}
className="absolute bottom-full mb-2 whitespace-nowrap bg-foreground text-background text-xs font-semibold px-3 py-1.5 rounded-lg shadow-xl"
>
{text}
<div className="absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-foreground" />
</motion.div>
)}
</AnimatePresence>
</div>
);
}
// Usage
<Tooltip text="Copy to clipboard">
<button className="p-2 bg-popover border border-border rounded-lg">๐</button>
</Tooltip>