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/image

Image

tool-ui/image
FreeBlock

Display images with metadata and attribution.

See it running

Open the demo on tool-ui

www.tool-ui.com/components/image
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/image.json

Source

components/tool-ui/image/image.tsxwww.tool-ui.com/r/image.json
1"use client";
2
3import * as React from "react";
4import { cn } from "./_adapter";
5
6import {
7 RATIO_CLASS_MAP,
8 getFitClass,
9 openSafeNavigationHref,
10 resolveSafeNavigationHref,
11 sanitizeHref,
12} from "../shared/media";
13import type { SerializableImage, Source } from "./schema";
14
15const FALLBACK_LOCALE = "en-US";
16
17export interface ImageProps extends SerializableImage {
18 className?: string;
19 onNavigate?: (href: string, image: SerializableImage) => void;
20}
21
22export function Image(props: ImageProps) {
23 const { className, onNavigate, ...serializable } = props;
24
25 const {
26 id,
27 src,
28 alt,
29 title,
30 href: rawHref,
31 domain,
32 ratio = "auto",
33 fit = "cover",
34 source,
35 locale: providedLocale,
36 } = serializable;
37
38 const locale = providedLocale ?? FALLBACK_LOCALE;
39 const sanitizedHref = sanitizeHref(rawHref);
40 const resolvedSourceUrl = sanitizeHref(source?.url);
41
42 const imageData: SerializableImage = {
43 ...serializable,
44 href: sanitizedHref,
45 source: source ? { ...source, url: resolvedSourceUrl } : undefined,
46 locale,
47 };
48
49 const sourceLabel = source?.label ?? domain;
50 const fallbackInitial = (sourceLabel ?? "").trim().charAt(0).toUpperCase();
51 const hasSource = Boolean(sourceLabel || source?.iconUrl);
52
53 const handleSourceClick = (event: React.MouseEvent<HTMLButtonElement>) => {
54 event.preventDefault();
55 event.stopPropagation();
56 const targetUrl = resolveSafeNavigationHref(
57 resolvedSourceUrl,
58 source?.url,
59 sanitizedHref,
60 src,
61 );
62 if (!targetUrl) return;
63 if (onNavigate) {
64 onNavigate(targetUrl, imageData);
65 } else {
66 openSafeNavigationHref(targetUrl);
67 }
68 };
69
70 const handleImageClick = () => {
71 if (!sanitizedHref) return;
72 if (onNavigate) {
73 onNavigate(sanitizedHref, imageData);
74 } else {
75 openSafeNavigationHref(sanitizedHref);
76 }
77 };
78
79 const hasMetadata = title || hasSource;
80
81 return (
82 <article
83 className={cn("relative w-full max-w-md min-w-80", className)}
84 lang={locale}
85 data-tool-ui-id={id}
86 data-slot="image"
87 >
88 <div
89 className={cn(
90 "group @container relative isolate flex w-full min-w-0 flex-col overflow-hidden rounded-xl",
91 "border-border bg-card border text-sm shadow-xs",
92 )}
93 >
94 <>
95 <div
96 className={cn(
97 "bg-muted group relative w-full overflow-hidden",
98// … truncated

What it pulls in

npm packages

  • zod

Files it writes

  • components/tool-ui/image/_adapter.tsx
  • components/tool-ui/image/image.tsx
  • components/tool-ui/image/index.ts
  • components/tool-ui/image/README.md
  • components/tool-ui/image/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
yesterday

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