Components
Hover Card
A customizable and accessible hover card component for displaying additional information on hover.
Introduction
The HoverCard
component is a lightweight, accessible component for showing additional content when hovering over a trigger element, such as buttons or links.
Default Use Case: Hover Card
Installation
Install the HoverCard
component using the following command:
File Structure
Prop Types
Prop | Type | Default |
---|---|---|
align | "center" | "start" | "end" | "center" |
sideOffset | number | 4 |
className | string | - |
Features
- Customizable:
- Adjust the alignment, offset, and appearance to match your design.
- Lightweight:
- Adds minimal overhead while offering a great user experience.
- Easy to Use:
- Wrap your content with
HoverCardTrigger
andHoverCardContent
.
- Wrap your content with
Accessibility
The HoverCard
component is fully accessible:
- ARIA Roles:
- Properly handles
aria-labelledby
andaria-describedby
.
- Properly handles
- Keyboard Navigation:
- Supports
Tab
andShift+Tab
for focus management.
- Supports
- Screen Reader Support:
- Screen readers announce the hover card content when triggered.
Conclusion
The HoverCard
component is perfect for displaying contextual information when users hover over elements like buttons or links. It combines flexibility, accessibility, and ease of use.