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.
Lightbox
Zoomable images inside Lightbox open in one viewer instead. Browse them with the arrow keys, by swiping, or with the side buttons.


Wrap your page content to browse every image on the page:
import { Lightbox } from "@/components/docs/components/image-zoom";
<DocsBody>
<Lightbox>
<MDX components={getMDXComponents()} />
</Lightbox>
</DocsBody>;The viewer shows an image's title as its caption, like "Light mode" in . Pass caption to ImageZoom for rich content such as links. To browse a set of images on its own, wrap them in another Lightbox.
The viewer is a native <dialog> with shadcn/ui buttons, and morphs the image in and out with a view transition where the browser supports them.
Props
Prop
Type