Components
Halftone Image
An image rendered as halftone dots.

<HalftoneImage>
<img src="/photo.jpg" alt="…" />
</HalftoneImage>Installation
npx shadcn@latest add https://ui.zjkm.tech/r/halftone-image.jsonimport { HalftoneImage } from "@/components/halftone-image"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Wrap an <img> or next/image, and it's redrawn as a grid of dots: the darker the area, the bigger the dot. Your image stays in place underneath, so its alt text and layout are untouched.
import { HalftoneImage } from "@/components/halftone-image";
export function Portrait() {
return (
<HalftoneImage cellSize={6}>
<img src="/team/ada.jpg" alt="Ada, our founder" />
</HalftoneImage>
);
}The effect reads the image's pixels, so an image from another site needs CORS headers and crossOrigin="anonymous". Without them, or without canvas support, the photo shows as-is.
It samples the whole image stretched to its box, so images cropped with object-fit: cover aren't matched exactly.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | The element that contains your <img>. | |
cellSize | number | 8 | Pixels per dot. |
color | string | "#111827" | Dot colour. |
background | string | "#ffffff" | Paper colour behind the dots. |
className | string | Classes for the wrapper. |
The halftone is static, so reduced motion changes nothing.