Install with shadcn/ui

Bring images closer with React

Lightweight image zoom for React.
Keep the source. Make it yours.

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

Try the zoom.

Scroll to explore
Landscape
Ocean sunsetPress Enter or Space to zoom. Click, press Escape, or scroll to close.
Portrait
Garden catPress Enter or Space to zoom. Click, press Escape, or scroll to close.
Source: NPS
Denali at sunrisePress Enter or Space to zoom. Click, press Escape, or scroll to close.
Source: NASA
Earth from spacePress Enter or Space to zoom. Click, press Escape, or scroll to close.
Source: NPS
Roosevelt ArchPress Enter or Space to zoom. Click, press Escape, or scroll to close.
Source: NPS
Aurora over YellowstonePress Enter or Space to zoom. Click, press Escape, or scroll to close.

Yours to change.

Typed React source. Install with shadcn/ui.

Keyboard and theme ready.

Accessible controls. Match your background.

High-resolution on demand.

Load sharper images only when zooming.

Add zoom to an image.

Use it like an image. Add your source, alt text, and styles.

Pass your source, alt text, and styles. The component handles zoom and keyboard access.

components/photo.tsx
import { ImageZoom } from "@/components/ui/image-zoom"

export function Photo() {
  return (
    <ImageZoom
      src="https://medium-zoom.francoischalifour.com/assets/images/ocean-sunset.jpg"
      alt="Ocean sunset"
      width={1920}
      height={1280}
      className="rounded-lg"
    />
  )
}

Works with SSR and React Server Components.

Small API. Sensible defaults.

Pass image attributes and zoom options to ImageZoom. Compose its parts for custom layouts.

ImageZoom component props
PropWhat it doesDefault
options.marginSpace around the zoomed image.24
options.backgroundOverlay color, resolved from your theme.--background
data-zoom-srcA higher-resolution source to open.Original image
openControl whether the image is zoomed.Internal state
onOpenChangeSet the next open value when controlling state.—
disabledDisable zoom; keep the image visible.false

Image attributes and the forwarded ref reach the underlying <img>. Explore all zoom options

Add zoom to your project.

Install with shadcn/ui. Make the component yours.

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
Read the documentation