Bring images closer with React
Lightweight image zoom for React.
Keep the source. Make it yours.
npx shadcn@latest add @medium-zoom/image-zoom
pnpm dlx shadcn@latest add @medium-zoom/image-zoom
yarn dlx shadcn@latest add @medium-zoom/image-zoom
bunx shadcn@latest add @medium-zoom/image-zoom
Try the zoom.
Scroll to explore
Ocean sunsetPress Enter or Space to zoom. Click, press Escape, or scroll to close.
Garden catPress Enter or Space to zoom. Click, press Escape, or scroll to close.
Denali at sunrisePress Enter or Space to zoom. Click, press Escape, or scroll to close.
Earth from spacePress Enter or Space to zoom. Click, press Escape, or scroll to close.
Roosevelt ArchPress Enter or Space to zoom. Click, press Escape, or scroll to close.
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.
| Prop | What it does | Default |
|---|---|---|
options.margin | Space around the zoomed image. | 24 |
options.background | Overlay color, resolved from your theme. | --background |
data-zoom-src | A higher-resolution source to open. | Original image |
open | Control whether the image is zoomed. | Internal state |
onOpenChange | Set the next open value when controlling state. | — |
disabled | Disable 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.
npx shadcn@latest add @medium-zoom/image-zoom
pnpm dlx shadcn@latest add @medium-zoom/image-zoom
yarn dlx shadcn@latest add @medium-zoom/image-zoom
bunx shadcn@latest add @medium-zoom/image-zoom