GitHub

Image Zoom

Image zoom component with lens (magnifying glass), side preview, inner zoom, and fullscreen zoom modes. Requires JavaScript to toggle active states on hover or click.

Basic Structure

Preview
Hover to zoom

Lens Mode (Round)

Preview
Hover for lens

Lens Mode (Square)

Preview
Square lens

Side Preview (Result Window)

Preview
Source image

Result Position Variants

Preview
Default (right)
image-zoom-result-left
image-zoom-result-top
image-zoom-result-bottom

Inner Zoom Mode

Preview
Hover to inner-zoom

Fullscreen Mode

Preview
Product Photo 100%
Fullscreen Image
100%

Zoom Icon Overlay

Preview
With search icon
With expand icon

Loading State

Preview
Loading high-res...

Classes Reference

Class Description
image-zoomBase container. Sets relative positioning, inline-block, overflow visible, zoom-in cursor.
image-zoom-activeActive state (add on hover). Hides cursor, shows lens/result/inner, hides zoom icon.
image-zoom-imgThe source image element. Block display, max-width 100%, non-draggable.
image-zoom-lensCircular magnifying glass element. 150px round, follows cursor, shows zoomed background.
image-zoom-lens-squareModifier on container. Changes lens from circle to rounded rectangle (uses --radius-field).
image-zoom-resultSide preview window. 400x400px, positioned to the right of the container by default.
image-zoom-result-leftModifier on container. Positions result window to the left.
image-zoom-result-topModifier on container. Positions result window above, centered.
image-zoom-result-bottomModifier on container. Positions result window below, centered.
image-zoom-inner-modeModifier on container. Enables inner zoom mode (overlay fills the container).
image-zoom-innerInner zoom overlay element. Absolute inset-0, shows zoomed background in-place.
image-zoom-iconZoom icon overlay in bottom-right corner. 32px circle, semi-transparent black background.
image-zoom-loadingLoading state on container. Reduces image opacity to 0.5.
image-zoom-spinnerLoading spinner. Centered, 32px, animated rotating border.
image-zoom-fullscreenFullscreen overlay container. Fixed inset-0, centered, z-50, hidden by default.
image-zoom-fullscreen-openShows the fullscreen overlay (opacity 1, visible).
image-zoom-fullscreen-backdropDark backdrop (95% black opacity).
image-zoom-fullscreen-containerInner container. Full width/height, flex column layout.
image-zoom-fullscreen-headerTop bar with gradient background. Contains title and close button.
image-zoom-fullscreen-titleImage title text in header. White, medium weight.
image-zoom-fullscreen-zoom-levelZoom percentage text in header. White at 70% opacity.
image-zoom-fullscreen-image-containerScrollable/pannable area for the image. Grab cursor, touch-action none.
image-zoom-fullscreen-image-wrapperTransform wrapper for zoom/pan. Will-change transform, smooth transitions.
image-zoom-fullscreen-imageThe fullscreen image element. Max-height calc(100dvh - 120px).
image-zoom-fullscreen-controlsBottom control bar. Centered pill with blur backdrop, zoom in/out/reset buttons.
image-zoom-fullscreen-btnControl button. 44px circle, translucent white background, hover/active states.
image-zoom-fullscreen-zoom-displayZoom percentage in controls bar. White text, min-width 48px.
image-zoom-fullscreen-closeClose button. Absolute top-right, 44px circle, respects safe-area-inset-top.
image-zoom-fullscreen-zoomedState class. Removes max-width/max-height constraints on image when zoomed in.
image-zoom-fullscreen-panningState class. Disables transitions on image wrapper during drag/pan.
image-zoom-fullscreen-hide-uiHides header and controls (opacity 0, pointer-events none).
image-zoom-fullscreen-activeSets cursor to pointer on the fullscreen container.

Responsive Behavior

Breakpoint Behavior
< 768pxResult window is hidden. Lens shrinks to 120px. Fullscreen buttons shrink to 40px.
prefers-reduced-motionAll transitions and the spinner animation are disabled.