The HoverCard component provides a hover-triggered card that displays additional content when users hover over a trigger element. It's commonly used for showing previews, additional information, or quick actions.
import { HoverCard } from '@dashflowx/core'export default function HoverCardExample() {return (<HoverCardhoverCardTrigger="Hover me"hoverCardContent="This is hover card content"/>)}
Preview:
| Prop | Type | Default | Description |
|---|---|---|---|
hoverCardTrigger | string | JSX.Element | 'Hover me' | The trigger element or text |
hoverCardContent | string | JSX.Element | 'This is hover card content' | The content to display in the hover card |
className | string | '' | Additional CSS classes for the container |
import { HoverCard } from '@dashflowx/core'export default function BasicHoverCard() {return (<HoverCardhoverCardTrigger="View Profile"hoverCardContent="John Doe - Software Engineer at Tech Corp"/>)}
Preview:
import { HoverCard } from '@dashflowx/core'export default function UserProfileHoverCard() {return (<HoverCardhoverCardTrigger="👤 @johndoe"hoverCardContent="John Doe - Software Engineer at Tech Corp. Passionate about React and TypeScript. Based in San Francisco."/>)}
Preview:
import { HoverCard } from '@dashflowx/core'export default function ProductPreviewHoverCard() {return (<HoverCardhoverCardTrigger="📱 iPhone 15 Pro"hoverCardContent="Latest iPhone with A17 Pro chip, titanium design, and advanced camera system. Starting at $999."/>)}
Preview:
import { HoverCard } from '@dashflowx/core'export default function LinkPreviewHoverCard() {return (<HoverCardhoverCardTrigger="🔗 Visit Website"hoverCardContent="React - A JavaScript library for building user interfaces. Learn more about React's features and capabilities."/>)}
Preview:
import { HoverCard } from '@dashflowx/core'export default function CustomStyledHoverCard() {return (<HoverCardhoverCardTrigger="🎨 Custom Style"hoverCardContent="This hover card has custom styling with different colors and layout."className="border-2 border-blue-500 rounded-xl"/>)}
Preview:
const userProfileCard = (<HoverCardhoverCardTrigger="👤 @username"hoverCardContent="Full Name - Job Title at Company. Brief bio and location information."/>);
const productCard = (<HoverCardhoverCardTrigger="🛍️ Product Name"hoverCardContent="Product description, price, and key features. Quick preview without leaving the page."/>);
const linkPreviewCard = (<HoverCardhoverCardTrigger="🔗 External Link"hoverCardContent="Website title and description. Preview of the linked content."/>);
const toolInfoCard = (<HoverCardhoverCardTrigger="🔧 Tool Name"hoverCardContent="Tool description, features, and usage examples. Quick reference information."/>);
const statusCard = (<HoverCardhoverCardTrigger="🟢 Online"hoverCardContent="User is currently online. Last seen 2 minutes ago. Available for chat."/>);
Use clear and descriptive trigger text.
// ✅ Good - Clear trigger<HoverCard hoverCardTrigger="View Profile" />// ❌ Avoid - Unclear trigger<HoverCard hoverCardTrigger="Click" />
Keep hover card content concise and relevant.
// ✅ Good - Concise content<HoverCard hoverCardContent="John Doe - Software Engineer" />// ❌ Avoid - Too much content<HoverCard hoverCardContent="John Doe is a software engineer who works at Tech Corp. He has been working there for 5 years and specializes in React development. He lives in San Francisco with his family and enjoys hiking on weekends..." />
Use hover cards for quick previews, not detailed information.
// ✅ Good - Quick preview<HoverCard hoverCardContent="Product: $29.99 - In Stock" />// ❌ Avoid - Detailed information<HoverCard hoverCardContent="This product is made from high-quality materials and includes a 2-year warranty. It's available in 5 colors and ships within 2-3 business days. Customer reviews average 4.5 stars..." />
Ensure hover card content is accessible to all users.
// ✅ Good - Accessible content<HoverCard hoverCardContent="User profile information" />// ❌ Avoid - Content that requires hover<HoverCard hoverCardContent="Hover over this text to see more" />
Maintain consistent styling across your application.
// ✅ Good - Consistent styling<HoverCard className="standard-hover-card" />// ❌ Avoid - Inconsistent styling<HoverCard className="random-styles" />
You can customize the hover card appearance using CSS classes:
<HoverCardhoverCardTrigger="Custom Styled"hoverCardContent="Custom content"className="border-2 border-purple-500 rounded-xl"/>
Use different themes for different contexts:
// Light theme<HoverCard className="bg-white border-gray-200" />// Dark theme<HoverCard className="bg-gray-900 border-gray-700 text-white" />// Brand theme<HoverCard className="bg-blue-50 border-blue-200" />
Use different sizes for different content types:
// Small hover card<HoverCard className="w-64" />// Medium hover card<HoverCard className="w-80" />// Large hover card<HoverCard className="w-96" />
Load hover card content dynamically:
const [hoverContent, setHoverContent] = useState('Loading...');useEffect(() => {// Load content based on triggerloadHoverContent(triggerId).then(setHoverContent);}, [triggerId]);
Show different content based on conditions:
const getHoverContent = (user) => {if (user.isOnline) {return `${user.name} - Online now`;}return `${user.name} - Last seen ${user.lastSeen}`;};
Include rich content in hover cards:
const richContent = (<div><h4>Product Name</h4><p>Description</p><div className="flex space-x-2"><button>Add to Cart</button><button>View Details</button></div></div>);
- Tooltip: For simple text tooltips
- Popover: For click-triggered content
- Card: For static content cards
- Button: For trigger elements
- Avatar: For user profile triggers
For the complete API reference and advanced usage patterns, see the HoverCard API documentation.
