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:

Anatomy
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.

PropTypeDefault
defaultOpen

boolean

false

open

boolean

undefined

onOpenChange

(open, event, reason) => void

undefined

delay

number

600

closeDelay

number

300

Trigger

A link that opens the preview card. Renders an <a> element.

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-popup-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>.

PropTypeDefault
container

React.Ref | HTMLElement | null

undefined

keepMounted

boolean

false

Backdrop

An overlay displayed beneath the popup. Renders a <div> element.

PropTypeDefault
className

string | (state) => string

undefined

keepMounted

boolean

false

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-open
data-closed
data-starting-style
data-ending-style

Positioner

Positions the popup against the trigger. Renders a <div> element.

PropTypeDefault
align

'start' | 'center' | 'end'

'center'

alignOffset

number

0

side

| 'bottom'
| 'inline-end'
| 'inline-start'
| 'left'
| 'right'
| 'top'

'bottom'

sideOffset

number

0

arrowPadding

number

5

anchor

| React.Ref
| Element
| VirtualElement
| (() => Element | VirtualElement | null)
| null

undefined

collisionBoundary

| 'clipping-ancestors'
| Element
| Element[]
| Rect

'clipping-ancestors'

collisionPadding

number | Rect

5

sticky

boolean

false

positionMethod

'absolute' | 'fixed'

'absolute'

className

string | (state) => string

undefined

keepMounted

boolean

false

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-open
data-closed
data-anchor-hidden
data-side
CSS Variable
Description
--anchor-height
--anchor-width
--available-height
--available-width
--transform-origin

A container for the preview card contents. Renders a <div> element.

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-open
data-closed
data-side
data-starting-style
data-ending-style

Arrow

Displays an element positioned against the preview card anchor. Renders a <div> element.

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-open
data-closed
data-uncentered
data-anchor-hidden
data-side