Skip to content
+

Preview Card

Preview Cards are visual-only interactive floating elements that display a concise preview of a link's contents when a user hovers over it before navigating through.

PreviewCardArrow API

Import

import * as PreviewCard from '@base_ui/react/PreviewCard';
const PreviewCardArrow = PreviewCard.Arrow;

Props

Props of the native component are also available.

NameTypeDefaultDescription
classNamefunc
| string
-

Class names applied to the element or a function that returns them based on the component's state.

hideWhenUncenteredboolfalse

Whether the Arrow is hidden when it can't point to the center of the anchor element.

renderelement
| func
-

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use PreviewCardArrow to change the default props of this component with the theme.

PreviewCardBackdrop API

Import

import * as PreviewCard from '@base_ui/react/PreviewCard';
const PreviewCardBackdrop = PreviewCard.Backdrop;

Props

Props of the native component are also available.

NameTypeDefaultDescription
classNamefunc
| string
-

Class names applied to the element or a function that returns them based on the component's state.

containerHTML element
| func
-

The element the Backdrop is appended to.

keepMountedboolfalse

Whether the Backdrop remains mounted when the Preview Card Popup is closed.

renderelement
| func
-

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use PreviewCardBackdrop to change the default props of this component with the theme.

PreviewCardPopup API

Import

import * as PreviewCard from '@base_ui/react/PreviewCard';
const PreviewCardPopup = PreviewCard.Popup;

Props

Props of the native component are also available.

NameTypeDescription
classNamefunc
| string

Class names applied to the element or a function that returns them based on the component's state.

renderelement
| func

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use PreviewCardPopup to change the default props of this component with the theme.

PreviewCardPositioner API

Import

import * as PreviewCard from '@base_ui/react/PreviewCard';
const PreviewCardPositioner = PreviewCard.Positioner;

Props

Props of the native component are also available.

NameTypeDefaultDescription
alignment'center'
| 'end'
| 'start'
'center'

The alignment of the preview card element to the anchor element along its cross axis.

alignmentOffsetnumber0

The offset of the preview card element along its alignment axis.

anchorHTML element
| object
| func
-

The anchor element to which the preview card popup will be placed at.

arrowPaddingnumber5

Determines the padding between the arrow and the preview card popup's edges. Useful when the preview card popup has rounded corners via border-radius.

classNamefunc
| string
-

Class names applied to the element or a function that returns them based on the component's state.

collisionBoundaryHTML element
| Array<HTML element>
| string
| { height?: number, width?: number, x?: number, y?: number }
'clippingAncestors'

The boundary that the preview card element should be constrained to.

collisionPaddingnumber
| { bottom?: number, left?: number, right?: number, top?: number }
5

The padding of the collision boundary.

containerHTML element
| func
-

The container element to which the preview card popup will be appended to.

hideWhenDetachedboolfalse

If true, the preview card will be hidden if it is detached from its anchor element due to differing clipping contexts.

keepMountedboolfalse

If true, preview card stays mounted in the DOM when closed.

positionStrategy'absolute'
| 'fixed'
'absolute'

The CSS position strategy for positioning the preview card popup element.

renderelement
| func
-

A function to customize rendering of the component.

side'bottom'
| 'left'
| 'right'
| 'top'
'bottom'

The side of the anchor element that the preview card element should align to.

sideOffsetnumber0

The gap between the anchor element and the preview card element.

stickyboolfalse

If true, allow the preview card to remain in stuck view while the anchor element is scrolled out of view.


The ref is forwarded to the root element.

Theme default props

You can use PreviewCardPositioner to change the default props of this component with the theme.

PreviewCardRoot API

Import

import * as PreviewCard from '@base_ui/react/PreviewCard';
const PreviewCardRoot = PreviewCard.Root;

Props

Props of the native component are also available.

NameTypeDefaultDescription
animatedbooltrue

Whether the preview card can animate, adding animation-related attributes and allowing for exit animations to play. Useful to disable in tests to remove async behavior.

closeDelaynumber300

The delay in milliseconds until the preview card popup is closed.

defaultOpenboolfalse

Whether the preview card popup is open by default. Use when uncontrolled.

delaynumber600

The delay in milliseconds until the preview card popup is opened.

delayType'hover'
| 'rest'
'rest'

The delay type to use when the preview card is triggered by hover. rest means the delay represents how long the user's cursor must rest on the trigger before the preview card popup is opened. hover means the delay represents how long to wait as soon as the user's cursor has entered the trigger.

onOpenChangefunc-

Callback fired when the preview card popup is requested to be opened or closed. Use when controlled.

openboolfalse

Whether the preview card popup is open. Use when controlled.


The component cannot hold a ref.

PreviewCardTrigger API

Import

import * as PreviewCard from '@base_ui/react/PreviewCard';
const PreviewCardTrigger = PreviewCard.Trigger;

Props

Props of the native component are also available.

NameTypeDescription
classNamefunc
| string

Class names applied to the element or a function that returns them based on the component's state.

renderelement
| func

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use PreviewCardTrigger to change the default props of this component with the theme.