HoverCard
A component that displays additional content when hovering over a trigger element, with smooth animations and positioning control.
Import
import {HoverCard,HoverCardTrigger,HoverCardContent,HoverCardPortal,HoverCardArrow} from "@sparrowengg/twigs-react";Usage
const HoverCardExample = () => {
return (
<Box css={{ display: "flex", flexDirection: "column", gap: "$6", alignItems: "center" }}>
<HoverCard openDelay={700} closeDelay={300}>
<HoverCardTrigger asChild>
<Button>
Hover over me
</Button>
</HoverCardTrigger>
<HoverCardContent side="bottom" align="center" sideOffset={8}>
<Box css={{ display: "flex", flexDirection: "column", gap: "$3" }}>
<Text css={{ fontWeight: "$6", fontSize: "$md" }}>Hover Card Title</Text>
<Text css={{ fontSize: "$sm", color: "$neutral600", lineHeight: "$md" }}>
This is a detailed description that appears when you hover over the trigger element.
</Text>
<Flex gap="$2" css={{ marginTop: "$2" }}>
<Button color={"default"} >
Feature 1
</Button>
<Button color={"default"}>
Feature 2
</Button>
</Flex>
</Box>
</HoverCardContent>
</HoverCard>
</Box>
);
};Props
HoverCard
| Prop | Type | Default |
|---|---|---|
defaultOpen? | boolean | - |
open? | boolean | - |
onOpenChange? | (open: boolean) => void | - |
openDelay? | number | 700 |
closeDelay? | number | 300 |
css? | object | - |
HoverCardTrigger
| Prop | Type | Default |
|---|---|---|
asChild? | boolean | false |
HoverCardContent
| Prop | Type | Default |
|---|---|---|
arrow? | boolean | true |
side? | 'top' | 'right' | 'bottom' | 'left' | 'bottom' |
sideOffset? | number | 0 |
align? | 'start' | 'center' | 'end' | 'center' |
alignOffset? | number | 0 |
avoidCollisions? | boolean | true |
collisionBoundary? | Boundary | [] |
collisionPadding? | number | Padding | 0 |
arrowPadding? | number | 0 |
sticky? | 'partial' | 'always' | 'partial' |
hideWhenDetached? | boolean | false |
forceMount? | boolean | - |
asChild? | boolean | false |
HoverCardPortal
| Prop | Type | Default |
|---|---|---|
forceMount? | boolean | - |
container? | HTMLElement | document.body |
Data Attributes
Applicable - HoverCardTrigger
| Prop | Type | Default |
|---|---|---|
[data-state]? | 'open' | 'closed' | - |
Applicable - HoverCardContent
| Prop | Type | Default |
|---|---|---|
[data-state]? | 'open' | 'closed' | - |
[data-side]? | 'top' | 'right' | 'bottom' | 'left' | - |
[data-align]? | 'start' | 'center' | 'end' | - |
Dropdown
A dropdown menu that displays a list of actions or functions triggered by a button. Supports items, checkboxes, radio groups, submenus, and separators with full keyboard navigation and accessibility features.
Popover
A component that displays rich content in a portal, triggered by a button. Perfect settings panels, and contextual information with smooth animations and positioning control.