React quickstart

Add the React component and render a zoomable image with <ImageZoom>.

Install the component

In a project configured for shadcn/ui, run:

Package manager
npx shadcn@latest add @medium-zoom/image-zoompnpm dlx shadcn@latest add @medium-zoom/image-zoomyarn dlx shadcn@latest add @medium-zoom/image-zoombunx shadcn@latest add @medium-zoom/image-zoom

The registry copies the component and stylesheet into your project and installs medium-zoom. You can edit those files to match your application.

Display an image

Import <ImageZoom> from your configured components directory. With the usual shadcn/ui alias:

photo.tsx
Press Enter or Space to zoom. Click, press Escape, or scroll to close.

Replace the image URL with your own. alt describes the image and labels the button. Width and height reserve space while the image loads.

Enter or Space on the button opens the image. Press Esc, click the enlarged image or its background, or scroll to close the zoom.

Browser support

The React component follows the browser requirements of your React application and its build tooling.

Next steps