Hover Card
Used to display content when hovering over an element
CUChakra UI
The most powerful toolkit for building modern web applications.
2.5M Downloads
Usage
import { HoverCard } from "@chakra-ui/react"<HoverCard.Root>
<HoverCard.Trigger />
<HoverCard.Positioner>
<HoverCard.Content>
<HoverCard.Arrow>
<HoverCard.ArrowTip />
</HoverCard.Arrow>
</HoverCard.Content>
</HoverCard.Positioner>
</HoverCard.Root>Shortcuts
The HoverCard provides a shortcuts for common use cases.
Arrow
The HoverCard.Arrow renders the HoverCard.ArrowTip component within in by
default.
This works:
<HoverCard.Arrow>
<HoverCard.ArrowTip />
</HoverCard.Arrow>This might be more concise, if you don't need to customize the arrow tip.
<HoverCard.Arrow />Examples
Controlled
Use the open and onOpenChange to control the visibility of the hover card.
Delays
Control the open and close delays using the openDelay and closeDelay props.
Placement
Use the positioning.placement prop to configure the underlying floating-ui
positioning logic.
Disabled
Use the disabled prop to prevent opening the hover card on interaction.
Chakra UI
The most powerful toolkit for building modern web applications.
Within Dialog
To use the HoverCard within a Dialog, you need to avoid portalling the
HoverCard.Positioner to the document's body.
-<Portal>
<HoverCard.Positioner>
<HoverCard.Content>
{/* ... */}
</HoverCard.Content>
</HoverCard.Positioner>
-</Portal>Accessibility
HoverCard should be used solely for supplementary information that is not essential for understanding the context.
It is inaccessible to screen readers and cannot be activated via keyboard, so avoid placing crucial content within it.
Props
| Prop | Default | Type |
|---|---|---|
closeDelay | 300 | numberThe duration from when the mouse leaves the trigger or content until the hover card closes. |
lazyMount | false | booleanWhether to enable lazy mounting |
openDelay | 700 | numberThe duration from when the mouse enters the trigger until the hover card opens. |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
colorPalette | gray | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'The color palette of the component |
size | md | 'xs' | 'sm' | 'md' | 'lg'The size of the component |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
unstyled | booleanWhether to remove the component's style. | |
defaultOpen | booleanThe initial open state of the hover card when rendered. Use when you don't need to control the open state of the hover card. | |
id | stringThe unique identifier of the machine. | |
ids | Partial<{ trigger: string; content: string; positioner: string; arrow: string }>The ids of the elements in the popover. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onFocusOutside | (event: FocusOutsideEvent) => voidFunction called when the focus is moved outside the component | |
onInteractOutside | (event: InteractOutsideEvent) => voidFunction called when an interaction happens outside the component | |
onOpenChange | (details: OpenChangeDetails) => voidFunction called when the hover card opens or closes. | |
onPointerDownOutside | (event: PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component | |
open | booleanThe controlled open state of the hover card | |
positioning | PositioningOptionsThe user provided options used to position the popover content | |
present | booleanWhether the node is present (controlled by the user) |
Explorer
Explore the Hover Card component parts interactively. Click on parts in the
sidebar to highlight them in the preview.
CUChakra UI
The most powerful toolkit for building modern web applications.
2.5M Downloads
Component Anatomy
Hover to highlight, click to select parts
arrow
arrowTip
trigger
positioner
content