Preview Card
Preview a link’s destination without leaving the current page.
Assigned to @ben
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/preview-cardComplete the one-time setup first. Registry JSON lists source files and dependencies.
For this page’s examples, also install:
pnpm dlx shadcn@4.18.0 add @siteplane/avatar @siteplane/progressUsage
import {
PreviewCard,
PreviewCardTrigger,
PreviewCardPopup,
} from "@/siteplane/components/preview-card";
<PreviewCard>
<PreviewCardTrigger href="#website-redesign">
Website Redesign
</PreviewCardTrigger>
<PreviewCardPopup>New marketing site, due October 30.</PreviewCardPopup>
</PreviewCard>;Composition
PreviewCard
├── PreviewCardTrigger (link)
└── PreviewCardPopupLink preview
Show where a link leads, such as a project, so people can decide whether to open it. The popup is 256px wide by default; give PreviewCardPopup a width such as w-80 when the content needs more room. This card pairs a project icon and title with a two-line description, and keeps the details compact with a Progress bar and the due date. The trigger stays a regular link, so it still works for people who don’t hover.
The latest designs are in Website Redesign.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
Preview | number | 600 | Milliseconds before the card opens. |
Preview | number | 300 | Milliseconds before the card closes. |
Preview | Positioner side | bottom | Side of the anchor the card opens on. |
Preview | start | center | end | center | Positioner alignment. |
Preview | Positioner sideOffset | 4 | Gap from anchor. |
Preview | Positioner alignOffset | 0 | Shift along the anchor's edge. |
Preview | Positioner anchor | trigger | Custom anchor. |
Preview | PreviewCardPrimitive.Portal.Props | unset | Portal options. |
open / default | boolean | false | Controlled or initial visibility. |
on | (open, eventDetails) => void | unset | Visibility callback. |
PreviewCard is the foundation Root; Trigger preserves link behavior; Popup
includes Portal and Positioner and defaults to a padded w-64 surface. Its
className is a string. PreviewCardPrimitive exposes Base UI Preview
Card. There is no
PreviewCardContent alias or complete positioner-props bag; Popup takes the
positioner's side, align, sideOffset, alignOffset and anchor directly. Other
trigger props, refs and root behavior follow the foundation.
Usage notes
Keep the destination understandable without hovering. The card is supplementary and should not contain required actions; use Popover or Dialog for a keyboard-driven interaction.