Image Zoom
Click an image and it grows from its spot on the page to fill the screen. Drag or flick it away to close.
Preview
Usage
import { ImageZoom } from '@vitnode/core/components/ui/image-zoom'<ImageZoom
alt="The VitNode AdminCP dashboard"
imageClassName="w-full rounded-md border"
src="/screenshots/dashboard.webp"
/>Click the image, or focus it and press Enter, and it glides to the middle of the screen. Click anywhere, press Escape or hit × to send it back.
Drag to dismiss
Grab the zoomed image and drag or flick it in any direction to close. Let go early and it springs back to the middle. The backdrop fades as you drag, so you can see where you're headed.
Sharper zoom
Show a light thumbnail and load the big file only on zoom:
<ImageZoom
alt="The VitNode AdminCP dashboard"
src={thumbnail}
zoomSrc={fullSize}
/>Styling
classNamestyles the clickable wrapper. Use it for layout and visibility, likehidden dark:blockfor theme-specific screenshots.imageClassNamestyles the image on the page.
The zoomed image always fits the screen without cropping.
Accessibility
- The image is a real button that opens a dialog.
altis required. It labels the image and names the zoomed view.- Focus is trapped while zoomed and returns to the image on close.
- Reduced motion zooms instantly. Reduced transparency swaps the blurred backdrop for a solid one.
Props
Prop
Type