---
title: "Link Preview"
description: "A link shown as a card with the page title, picture, and site name, so people see where it goes. It comes as a card, a compact row, a chip, or a hover card."
url: https://gelatinui.com/components/link-preview
markdown_url: https://gelatinui.com/components/link-preview.md
access: free
install: "npx shadcn@latest add @gelatin-ui/link-preview"
registry_item: https://gelatinui.com/r/link-preview.json
version: "2026-11-17"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Link Preview

> A link shown as a card with the page title, picture, and site name, so people see where it goes. It comes as a card, a compact row, a chip, or a hover card.

Page: https://gelatinui.com/components/link-preview

## When to use it

Best for: Links that people share in chats, comments, and docs, shown with the page title, picture, and site.

- Use it when the app has the page title and picture, from its own server or from data it keeps.
- Use `variant="compact"` in a narrow list and `variant="inline"` inside a sentence.
- Use `LinkPreviewHover` when the link must stay text and the card is extra.

## When not to use it

- For a preview of a person or a repository behind a link, with your own content, use a [Hover Card](https://gelatinui.com/components/hover-card.md).
- For a file that a person attached, use an [Attachment](https://gelatinui.com/components/attachment.md).

## Notes for agents

- The item never fetches a URL. Give `LinkPreviewProvider` an adapter with `getPreview(href, { signal })`; read the page on your server and check the address there.
- `getPreview` resolves `null` for a page with no preview (the plain address shows) and rejects on an error.
- Pass `data` to show a preview the app has already; then no provider is needed.
- Only `http:` and `https:` addresses render as a link. Any other address shows as plain text.
- Put `LinkPreviewError` inside `LinkPreview` to show the error with Retry to the writer; without it, readers see the plain address.
- Keep `adapter` stable: a new adapter starts a new cache.

## Anatomy

```text
LinkPreview
├─ LinkPreviewCard (0..n)
├─ LinkPreviewContent (0..n)
├─ LinkPreviewImage (0..n)
├─ LinkPreviewSite (0..n)
├─ LinkPreviewTitle (0..n)
├─ LinkPreviewDescription (0..n)
├─ LinkPreviewMeta (0..n)
├─ LinkPreviewFallback (0..n)
├─ LinkPreviewError (0..n)
├─ LinkPreviewRetry (0..n)
├─ LinkPreviewHoverTrigger (0..n)
└─ LinkPreviewHoverContent (0..n)
```

## API reference

### LinkPreview

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `href` | `string` |  | The address. Only `http:` and `https:` links render as a link; any other shows as text. |
| `variant` | `NonNullable` | "card" | The look: `card` (text and a picture at the end), `stacked`, `compact`, or `inline`. |
| `data` | `LinkPreviewData \| null` |  | The preview when the app has it already (`null`: the page has no preview). Leave it out to read it through the `LinkPreviewProvider` adapter. |
| `status` | `DataStatus` |  | The load state, when the app owns it (a story, a server render). Default: from the data. |
| `labels` | `Partial<LinkPreviewLabels>` |  | The words the item writes itself. |
| `children` | `ReactNode` |  | The parts. Default: the card of the variant (`LinkPreviewCard`). |

### LinkPreviewCard

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewContent

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewImage

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewSite

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewTitle

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewDescription

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewMeta

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewFallback

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewError

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### LinkPreviewRetry

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` | "default" |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "outline" |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### LinkPreviewHover

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `href` | `string` |  | The address the text link opens and the card previews. |
| `data` | `LinkPreviewData \| null` |  | The preview when the app has it already; else the provider adapter reads it on open. |
| `children` | `ReactNode` |  | The trigger and the card: `LinkPreviewHoverTrigger` and `LinkPreviewHoverContent`. |

Also takes every prop of Base UI `PreviewCard.Root`: https://base-ui.com/react/components/preview-card

### LinkPreviewHoverTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `PreviewCard.Trigger`: https://base-ui.com/react/components/preview-card

### LinkPreviewHoverContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `arrow` | `boolean` |  | Show an arrow that points at the link. The gap grows from 4px to 8px. |
| `backdrop` | `boolean` |  | Put a clear layer under the card (Base UI `PreviewCard.Backdrop`). Hover on the page stops. |
| `portalProps` | `Omit` |  | Other Base UI props of the inner parts. A `className` here adds to the component classes. |
| `positionerProps` | `PopupPartProps` |  |  |
| `backdropProps` | `PopupPartProps<PreviewCardBackdropProps>` |  |  |
| `arrowProps` | `PopupPartProps<PreviewCardArrowProps>` |  |  |
| `children` | `ReactNode` |  |  |

Also takes every prop of Base UI `PreviewCard.Portal`: https://base-ui.com/react/components/preview-card

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| LinkPreview | `link-preview` |  |  |  |
| LinkPreviewCard | `link-preview-card` |  |  |  |
| LinkPreviewContent | `link-preview-content` |  |  |  |
| LinkPreviewImage | `link-preview-image` |  | `--radius` |  |
| LinkPreviewSite | `link-preview-site` |  |  |  |
| LinkPreviewTitle | `link-preview-title` |  |  |  |
| LinkPreviewDescription | `link-preview-description` |  |  |  |
| LinkPreviewMeta | `link-preview-meta` |  |  |  |
| LinkPreviewFallback | `link-preview-fallback` |  |  |  |
| LinkPreviewError | `link-preview-error` |  | `--radius` | `status-colors` |
| LinkPreviewRetry | `link-preview-retry` |  |  |  |
| LinkPreviewHoverTrigger | `link-preview-hover-trigger` |  |  |  |
| LinkPreviewHoverContent | `link-preview-hover-content` |  | `--motion-press-scale`, `--radius` |  |

## Usage

Wrap the page in `LinkPreviewProvider` with your adapter, then compose each `LinkPreview` with its parts.

```tsx title="shared-links.tsx"
import {
  LinkPreview,
  LinkPreviewCard,
  LinkPreviewError,
  LinkPreviewProvider,
} from "@/components/ui/link-preview";
import type { LinkPreviewAdapter } from "@/lib/link-preview-store";

// Your server reads the page and its Open Graph tags; the item never fetches a URL.
const adapter: LinkPreviewAdapter = {
  getPreview: async (href, { signal }) => {
    const response = await fetch(`/api/link-preview?url=${encodeURIComponent(href)}`, { signal });
    if (!response.ok) {
      throw new Error(`Link preview failed with ${response.status}`);
    }
    return response.json();
  },
};

export function SharedLinks() {
  return (
    <LinkPreviewProvider adapter={adapter}>
      <div className="flex max-w-md flex-col gap-3">
        <LinkPreview href="https://gelatinui.com/blog/checkout">
          <LinkPreviewCard />
          <LinkPreviewError>Could not read this page.</LinkPreviewError>
        </LinkPreview>
        <LinkPreview href="https://northwind.studio/q4" variant="compact">
          <LinkPreviewCard />
        </LinkPreview>
      </div>
    </LinkPreviewProvider>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/link-preview
```

It adds 47 registry items: 43 files, 6541 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@unpic/core`, `@xstate/react`, `clsx`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Hover Card](https://gelatinui.com/components/hover-card.md)
- [Image](https://gelatinui.com/components/image.md)
- [Skeleton](https://gelatinui.com/components/skeleton.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Hover Card](https://gelatinui.com/components/hover-card.md)
- [Image](https://gelatinui.com/components/image.md)
- [Card](https://gelatinui.com/components/card.md)

## Motion

| Part | Motion |
| --- | --- |
| Press | press · 100ms · the card scales to 97% |
| Hover | hover · 150ms · the border and fill tint change, and the compact arrow moves up and out |
| Picture | panel · 260ms · ease-panel (0.2, 0.4, 0.2, 1) · the picture scales to 102% on hover |
| Hover card | popup · 150ms · the card fades in and scales from 95% after 500ms of hover or on focus |
