Image zoom
An image that zooms in to fill the screen when clicked.
Installation
npx shadcn@latest add @docscn/image-zoomUsage
ImageZoom takes the props of Next.js' Image. To make every image in your content zoomable, render Markdown images with it in components/mdx.tsx:
import {
ImageZoom,
type ImageZoomProps,
} from "@/components/docs/components/image-zoom";
export function getMDXComponents(components?: MDXComponents) {
return {
...defaultMdxComponents,
img: (props) => <ImageZoom {...(props as ImageZoomProps)} />,
...components,
} satisfies MDXComponents;
}It's built on react-medium-image-zoom. Installing it adds the styles the zoomed image needs to your global stylesheet, with the page's --background behind the image.
Props
Prop
Type