Preview Card
A popup that appears when a link is hovered, showing a preview for sighted users.
The principles of good typography remain into the digital age.
API reference
Import the component and place its parts the following way:
import { PreviewCard } from '@base-ui-components/react/previewCard';
<PreviewCard.Root>
  <PreviewCard.Trigger />
  <PreviewCard.Portal>
    <PreviewCard.Backdrop />
    <PreviewCard.Positioner>
      <PreviewCard.Popup>
        <PreviewCard.Arrow />
      </PreviewCard.Popup>
    </PreviewCard.Positioner>
  </PreviewCard.Portal>
</PreviewCard.Root>Root
Groups all parts of the preview card. Doesn’t render its own HTML element.
| Prop | Type | Default | |
|---|---|---|---|
closeDelay | number | 300 | |
defaultOpen | boolean | false | |
delay | number | 600 | |
onOpenChange | (open, event, reason) => void | undefined | |
open | boolean | undefined | 
Trigger
A link that opens the preview card.
Renders an <a> element.
| Prop | Type | Default | |
|---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined | 
| Attribute | Description  | |
|---|---|---|
data-popup-open | Present when the corresponding preview card is open.  | |
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>.
| Prop | Type | Default | |
|---|---|---|---|
container | React.Ref | HTMLElement | null | undefined | |
keepMounted | boolean | false | 
Backdrop
An overlay displayed beneath the popup.
Renders a <div> element.
| Prop | Type | Default | |
|---|---|---|---|
className | string | (state) => string | undefined | |
keepMounted | boolean | false | |
render | | React.ReactElement | undefined | 
| Attribute | Description  | |
|---|---|---|
data-closed | Present when the preview card is closed.  | |
data-ending-style | Present when the preview card is animating out.  | |
data-open | Present when the preview card is open.  | |
data-starting-style | Present when the preview card is animating in.  | |
Positioner
Positions the popup against the trigger.
Renders a <div> element.
| Prop | Type | Default | |
|---|---|---|---|
align | 'start' | 'center' | 'end' | 'center' | |
alignOffset | number | 0 | |
anchor | | React.Ref | undefined | |
arrowPadding | number | 5 | |
className | string | (state) => string | undefined | |
collisionBoundary | | 'clippingAncestors' | 'clipping-ancestors' | |
collisionPadding | number | Rect | 5 | |
keepMounted | boolean | false | |
positionMethod | 'absolute' | 'fixed' | 'absolute' | |
render | | React.ReactElement | undefined | |
side | | 'bottom' | 'bottom' | |
sideOffset | number | 0 | |
sticky | boolean | false | 
| Attribute | Description  | |
|---|---|---|
data-anchor-hidden | Present when the anchor is hidden.  | |
data-open | Present when the preview card is open.  | |
data-side | Indicates which side the preview card is positioned relative to the trigger.  | |
data-unchecked | Present when the preview card is closed.  | |
| CSS Variable | Description  | |
|---|---|---|
--anchor-height | The anchor's height.  | |
--anchor-width | The anchor's width.  | |
--available-height | The available height between the trigger and the edge of the viewport.  | |
--available-width | The available width between the trigger and the edge of the viewport.  | |
--transform-origin | The coordinates that this element is anchored to. Used for animations and transitions.  | |
Popup
A container for the preview card contents.
Renders a <div> element.
| Prop | Type | Default | |
|---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined | 
| Attribute | Description  | |
|---|---|---|
data-closed | Present when the preview card is closed.  | |
data-ending-style | Present when the preview card is animating out.  | |
data-open | Present when the preview card is open.  | |
data-side | Indicates which side the preview card is positioned relative to the trigger.  | |
data-starting-style | Present when the preview card is animating in.  | |
Arrow
Displays an element positioned against the preview card anchor.
Renders a <div> element.
| Prop | Type | Default | |
|---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined | 
| Attribute | Description  | |
|---|---|---|
data-anchor-hidden | Present when the anchor is hidden.  | |
data-open | Present when the preview card is open.  | |
data-side | Indicates which side the preview card is positioned relative to the trigger.  | |
data-uncentered | Present when the tooltip arrow is uncentered.  | |
data-unchecked | Present when the preview card is closed.  | |