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 assemble its parts:
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 | |
---|---|---|---|
defaultOpen |
|
| |
open |
|
| |
onOpenChange |
|
| |
delay |
|
| |
closeDelay |
|
|
Trigger
A link that opens the preview card.
Renders an <a>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
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 |
|
| |
keepMounted |
|
|
Backdrop
An overlay displayed beneath the popup.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
keepMounted |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the preview card is open. | |
data-closed | Present when the preview card is closed. | |
data-starting-style | Present when the preview card is animating in. | |
data-ending-style | Present when the preview card is animating out. |
Positioner
Positions the popup against the trigger.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
align |
|
| |
alignOffset |
|
| |
side |
|
| |
sideOffset |
|
| |
arrowPadding |
|
| |
anchor |
|
| |
collisionBoundary |
|
| |
collisionPadding |
|
| |
sticky |
|
| |
positionMethod |
|
| |
className |
|
| |
keepMounted |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the preview card is open. | |
data-closed | Present when the preview card is closed. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-side | Indicates which side the preview card is positioned relative to the trigger. |
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 |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the preview card is open. | |
data-closed | Present when the preview card is closed. | |
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. | |
data-ending-style | Present when the preview card is animating out. |
Arrow
Displays an element positioned against the preview card anchor.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the preview card is open. | |
data-closed | Present when the preview card is closed. | |
data-uncentered | Present when the preview card arrow is uncentered. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-side | Indicates which side the preview card is positioned relative to the trigger. |