
Rich content card that appears on hover, built on Base UI PreviewCard.
pnpm dlx edbn-ui@latest add hover-cardCreate a file and paste the following code into it.
Groups all parts of the hover card. Uses Base UI PreviewCard.Root and doesn't render its own HTML element.
defaultOpenbooleanfalseInitial open state
openbooleanControlled open state
onOpenChange(open: boolean, details: PreviewCard.Root.ChangeEventDetails) => voidCalled when the hover card opens or closes
onOpenChangeComplete(open: boolean) => voidCalled after animation completes
actionsRefRefObject<PreviewCard.Root.Actions | null>Imperative close and unmount actions
handlePreviewCard.Handle<Payload>Handle for detached hover card triggers
defaultTriggerIdstring | nullInitial associated trigger id
triggerIdstring | nullControlled associated trigger id
childrenReactNode | PayloadChildRenderFunction<Payload>Hover card content or payload-aware render child
A link that opens the hover card on hover or focus. Renders an a element.
handlePreviewCard.Handle<Payload>Associates this trigger with a detached root
payloadPayloadPayload passed to a render-child root
delaynumber600Delay before hover/focus open in milliseconds
closeDelaynumber300Delay before closing after pointer leaves
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-popup-open | Present when card is open |
Moves the popup to a different part of the DOM. Renders a div element.
containerHTMLElement | ShadowRoot | RefObject | nullPortal container
keepMountedbooleanfalseKeep in DOM when closed
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
An overlay displayed beneath the hover card popup. Renders a div element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when card is open |
| data-closed | Present when card is closed |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
Positions the popup against the trigger. Renders a div element.
sideSide'bottom'Side relative to anchor
sideOffsetnumber | OffsetFunction0Distance from anchor
alignOffsetnumber | OffsetFunction0Offset along the alignment axis
arrowPaddingnumber5Minimum arrow distance from popup edges
anchorElement | VirtualElement | RefObject | function | nullCustom positioning anchor
collisionAvoidanceCollisionAvoidanceFlip, shift, or disable collision handling
collisionBoundaryBoundary'clipping-ancestors'Boundary used for collision detection
collisionPaddingPadding5Space from the collision boundary
disableAnchorTrackingbooleanfalseDisable tracking layout shifts of the anchor
stickybooleanfalseKeep visible after the anchor scrolls away
positionMethod'absolute' | 'fixed''absolute'CSS positioning strategy
align'start' | 'center' | 'end''center'Alignment relative to side
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when popup is open |
| data-closed | Present when popup is closed |
| data-anchor-hidden | Present when the anchor is hidden |
| data-side | Side popup is positioned on |
| data-align | Alignment relative to side |
| Variable | Description |
|---|---|
| --anchor-height | Anchor height |
| --anchor-width | Anchor width |
| --available-height | Available height between anchor and viewport edge |
| --available-width | Available width between anchor and viewport edge |
| --transform-origin | Transform origin for anchored animations |
A container for the hover card contents. Renders a div element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when card is open |
| data-closed | Present when card is closed |
| data-align | Alignment relative to side |
| data-instant | Present when animations should be skipped |
| data-side | Side popup is positioned on |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
| Variable | Description |
|---|---|
| --popup-height | Current popup height |
| --popup-width | Current popup width |
Displays an arrow element positioned against the anchor. Renders a div element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when card is open |
| data-closed | Present when card is closed |
| data-uncentered | Present when the arrow cannot be centered |
| data-align | Alignment relative to side |
| data-side | Side popup is positioned on |
A viewport for animating content transitions between trigger payloads. Renders a div element.
childrenReactNodeContent to render inside the transition container
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-activation-direction | Direction from the previous trigger to the new trigger |
| data-current | Applied to the current content container |
| data-instant | Present when animations should be skipped |
| data-previous | Applied to the exiting content container |
| data-transitioning | Present while content is transitioning |
| Variable | Description |
|---|---|
| --popup-height | Parent popup height for transition containers |
| --popup-width | Parent popup width for transition containers |
Base UI handle utility for detached triggers and imperative hover card control.
isOpenbooleanreadonlyWhether the associated hover card is open
open(triggerId: string) => voidmethodOpen and associate the hover card with a trigger id
close() => voidmethodClose the associated hover card
Function exported as createHoverCardHandle for creating typed detached-trigger handles.
returnPreviewCard.Handle<Payload>A new imperative hover card handle