Preview Card

A card that appears on hover to preview linked content.

Newoverlaydisplay
Loading preview...

Installation

Terminal
npx baseui-cn add preview-card

Usage

Code
import { PreviewCard, PreviewCardTrigger, PreviewCardContent } from "@/components/ui/preview-card"
Code
<PreviewCard>
  <PreviewCardTrigger href="https://example.com">Hover me</PreviewCardTrigger>
  <PreviewCardContent>
    <p>Preview content here.</p>
  </PreviewCardContent>
</PreviewCard>

Examples

Basic

A simple preview card with text content.

Loading preview...

Placement

Use the side prop on PreviewCardContent to control placement: top, right, bottom (default).

Loading preview...

API

PreviewCardContent

PropTypeDefaultDescription
side"top" | "bottom" | "left" | "right""bottom"Side of the trigger the card opens on
sideOffsetnumber4Distance in px between the card and the trigger
align"start" | "center" | "end""center"Alignment relative to the trigger
alignOffsetnumber4Offset in px along the alignment axis

positionerProps forwards native Base UI Positioner options, including anchor, collision boundaries/padding, positioning method and refs. Options supplied there override the convenience positioning props above.

API Reference

See the Base UI PreviewCard documentation for the full API reference, including all props, data attributes, and CSS classes.