BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/tool-ui/link-preview

Link Preview

tool-ui/link-preview
FreeBlock

Rich link previews with OG data.

See it running

Open the demo on tool-ui

www.tool-ui.com/components/link-preview
Open
This registry sends X-Frame-Options, so its page cannot be embedded here. The link is the same page the frame would have shown.

Install it

npx shadcn@latest add https://www.tool-ui.com/r/link-preview.json

Source

components/tool-ui/link-preview/link-preview.tsxwww.tool-ui.com/r/link-preview.json
1"use client";
2
3import { Globe } from "lucide-react";
4import { cn } from "./_adapter";
5
6import {
7 RATIO_CLASS_MAP,
8 getFitClass,
9 openSafeNavigationHref,
10 sanitizeHref,
11} from "../shared/media";
12import type { SerializableLinkPreview } from "./schema";
13
14const FALLBACK_LOCALE = "en-US";
15const CONTENT_SPACING = "px-5 py-4 gap-2";
16
17export interface LinkPreviewProps extends SerializableLinkPreview {
18 className?: string;
19 onNavigate?: (href: string, preview: SerializableLinkPreview) => void;
20}
21
22export function LinkPreview(props: LinkPreviewProps) {
23 const { className, onNavigate, ...serializable } = props;
24
25 const {
26 id,
27 href: rawHref,
28 title,
29 description,
30 image,
31 domain,
32 favicon,
33 ratio = "16:9",
34 fit = "cover",
35 locale: providedLocale,
36 } = serializable;
37
38 const locale = providedLocale ?? FALLBACK_LOCALE;
39 const sanitizedHref = sanitizeHref(rawHref);
40
41 const previewData: SerializableLinkPreview = {
42 ...serializable,
43 href: sanitizedHref ?? rawHref,
44 locale,
45 };
46
47 const handleClick = () => {
48 if (!sanitizedHref) return;
49 if (onNavigate) {
50 onNavigate(sanitizedHref, previewData);
51 } else {
52 openSafeNavigationHref(sanitizedHref);
53 }
54 };
55
56 return (
57 <article
58 className={cn("relative w-full max-w-md min-w-80", className)}
59 lang={locale}
60 data-tool-ui-id={id}
61 data-slot="link-preview"
62 >
63 <div
64 className={cn(
65 "group @container relative isolate flex w-full min-w-0 flex-col overflow-hidden rounded-xl",
66 "border-border bg-card border text-sm shadow-xs",
67 sanitizedHref && "cursor-pointer",
68 )}
69 onClick={sanitizedHref ? handleClick : undefined}
70 role={sanitizedHref ? "link" : undefined}
71 tabIndex={sanitizedHref ? 0 : undefined}
72 onKeyDown={
73 sanitizedHref
74 ? (e) => {
75 if (e.key === "Enter" || e.key === " ") {
76 e.preventDefault();
77 handleClick();
78 }
79 }
80 : undefined
81 }
82 >
83 <div className="flex flex-col">
84 {image && (
85 <div
86 className={cn(
87 "bg-muted relative w-full overflow-hidden",
88 ratio !== "auto" ? RATIO_CLASS_MAP[ratio] : "aspect-[5/3]",
89 )}
90 >
91 <img
92 src={image}
93 alt=""
94 loading="lazy"
95 decoding="async"
96// … truncated

What it pulls in

npm packages

  • lucide-react
  • zod

Files it writes

  • components/tool-ui/link-preview/_adapter.tsx
  • components/tool-ui/link-preview/index.ts
  • components/tool-ui/link-preview/link-preview.tsx
  • components/tool-ui/link-preview/README.md
  • components/tool-ui/link-preview/schema.ts
  • components/tool-ui/shared/contract.ts
  • components/tool-ui/shared/media/aspect-ratio.ts
  • components/tool-ui/shared/media/format-utils.ts
  • components/tool-ui/shared/media/index.ts
  • components/tool-ui/shared/media/overlay-gradient.ts
  • components/tool-ui/shared/media/safe-navigation.ts
  • components/tool-ui/shared/media/sanitize-href.ts
  • components/tool-ui/shared/parse.ts
  • components/tool-ui/shared/schema.ts

Facts

Registry
tool-ui
Type
registry:block
Access
Free
Files written
14
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
today

Go to the source

Docs on tool-ui www.tool-ui.com Raw registry item This item as JSON

More from tool-ui

All 27 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Approval Cardapproval-cardtool-uiBlocksFree2 deps · 11 files
Audioaudiotool-uiBlocksFree2 deps · 9 files
Chartcharttool-uiBlocksFree2 deps · 8 files
Citationcitationtool-uiBlocksFree2 deps · 15 files
Code Blockcode-blocktool-uiBlocksFree3 deps · 11 files
Code Diffcode-difftool-uiBlocksFree3 deps · 10 files
Data Tabledata-tabletool-uiBlocksFree1 dep · 17 files
Geo Mapgeo-maptool-uiBlocksFree4 deps · 12 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex