Preview Card
A preview card displays a rich preview of content when hovering over or focusing on a trigger element. It’s similar to a popover but specifically designed for preview/hover interactions.Import
Basic Usage
Sub-components
Root
Groups all parts of the preview card. Doesn’t render its own HTML element. Key Props:open(boolean): Whether the preview card is currently opendefaultOpen(boolean): Whether the preview card is initially open (default:false)onOpenChange((open: boolean, eventDetails) => void): Event handler called when the preview card is opened or closedonOpenChangeComplete((open: boolean) => void): Event handler called after animations completehandle(PreviewCardHandle): A handle to associate the preview card with an external triggeractionsRef(React.RefObject): A ref to imperative actions (unmount,close)
Trigger
The element that triggers the preview card on hover or focus.Portal
Portals the preview card content to a different part of the DOM.Positioner
Positions the preview card relative to the trigger using Floating UI. Key Props:anchor(Element | VirtualElement): The anchor element to which the preview card is positionedside(‘top’ | ‘right’ | ‘bottom’ | ‘left’): The side of the anchor to position against (default:'bottom')alignment(‘start’ | ‘center’ | ‘end’): The alignment relative to the anchor (default:'center')sideOffset(number): The distance in pixels from the anchor (default:0)
Popup
The container for the preview card content.Arrow
An optional arrow that points to the trigger element.Backdrop
An optional backdrop element.Viewport
Defines the viewport element to which the preview card is confined.Styling Example
Key Features
- Opens on hover or focus (not click)
- Automatic positioning with collision detection
- Smooth enter/exit animations
- Arrow pointing to trigger
- Delay before showing/hiding
- Nested preview card support
Accessibility
- Appropriate ARIA attributes for screen readers
- Keyboard accessible via focus
- Respects reduced motion preferences
- Can be dismissed with Escape key
- Pointer-safe areas prevent accidental closing