coss.com Svelte

Preview Card

A popup that appears when a link is hovered, showing a preview for sighted users.

API Reference
Loading p-preview-card-1 preview…

Installation

pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/preview-card.json

Usage

<script lang="ts">
  import * as PreviewCard from "$lib/components/ui/preview-card/index.js";
</script>

<PreviewCard.Root>
  <PreviewCard.Trigger href="/">Open Preview Card</PreviewCard.Trigger>
  <PreviewCard.Popup>Preview Card Content</PreviewCard.Popup>
</PreviewCard.Root>

API Reference

PreviewCard.Root

Root component. Wraps PreviewCard.Root from Shards UI.

PreviewCard.Trigger

Trigger element that shows the preview card on hover. Wraps PreviewCard.Trigger from Shards UI.

PreviewCard.Popup

Popup container that displays the preview content. Also exported as PreviewCard.HoverCardContent.

PropTypeDefaultDescription
align"start" \| "center" \| "end""center"Alignment relative to the trigger
sideOffsetnumber4Distance from the trigger in pixels
portalPropsComponentProps<typeof PreviewCard.PreviewCardPrimitive.Portal>-Props forwarded to the internal portal (keepMounted, container, etc.); see the Shards UI Preview Card portal API