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
Zoom Icon Overlay
Preview
With search icon
With expand icon
Loading State
Preview
Loading high-res...
Classes Reference
| Class | Description |
|---|---|
image-zoom | Base container. Sets relative positioning, inline-block, overflow visible, zoom-in cursor. |
image-zoom-active | Active state (add on hover). Hides cursor, shows lens/result/inner, hides zoom icon. |
image-zoom-img | The source image element. Block display, max-width 100%, non-draggable. |
image-zoom-lens | Circular magnifying glass element. 150px round, follows cursor, shows zoomed background. |
image-zoom-lens-square | Modifier on container. Changes lens from circle to rounded rectangle (uses --radius-field). |
image-zoom-result | Side preview window. 400x400px, positioned to the right of the container by default. |
image-zoom-result-left | Modifier on container. Positions result window to the left. |
image-zoom-result-top | Modifier on container. Positions result window above, centered. |
image-zoom-result-bottom | Modifier on container. Positions result window below, centered. |
image-zoom-inner-mode | Modifier on container. Enables inner zoom mode (overlay fills the container). |
image-zoom-inner | Inner zoom overlay element. Absolute inset-0, shows zoomed background in-place. |
image-zoom-icon | Zoom icon overlay in bottom-right corner. 32px circle, semi-transparent black background. |
image-zoom-loading | Loading state on container. Reduces image opacity to 0.5. |
image-zoom-spinner | Loading spinner. Centered, 32px, animated rotating border. |
image-zoom-fullscreen | Fullscreen overlay container. Fixed inset-0, centered, z-50, hidden by default. |
image-zoom-fullscreen-open | Shows the fullscreen overlay (opacity 1, visible). |
image-zoom-fullscreen-backdrop | Dark backdrop (95% black opacity). |
image-zoom-fullscreen-container | Inner container. Full width/height, flex column layout. |
image-zoom-fullscreen-header | Top bar with gradient background. Contains title and close button. |
image-zoom-fullscreen-title | Image title text in header. White, medium weight. |
image-zoom-fullscreen-zoom-level | Zoom percentage text in header. White at 70% opacity. |
image-zoom-fullscreen-image-container | Scrollable/pannable area for the image. Grab cursor, touch-action none. |
image-zoom-fullscreen-image-wrapper | Transform wrapper for zoom/pan. Will-change transform, smooth transitions. |
image-zoom-fullscreen-image | The fullscreen image element. Max-height calc(100dvh - 120px). |
image-zoom-fullscreen-controls | Bottom control bar. Centered pill with blur backdrop, zoom in/out/reset buttons. |
image-zoom-fullscreen-btn | Control button. 44px circle, translucent white background, hover/active states. |
image-zoom-fullscreen-zoom-display | Zoom percentage in controls bar. White text, min-width 48px. |
image-zoom-fullscreen-close | Close button. Absolute top-right, 44px circle, respects safe-area-inset-top. |
image-zoom-fullscreen-zoomed | State class. Removes max-width/max-height constraints on image when zoomed in. |
image-zoom-fullscreen-panning | State class. Disables transitions on image wrapper during drag/pan. |
image-zoom-fullscreen-hide-ui | Hides header and controls (opacity 0, pointer-events none). |
image-zoom-fullscreen-active | Sets cursor to pointer on the fullscreen container. |
Responsive Behavior
| Breakpoint | Behavior |
|---|---|
< 768px | Result window is hidden. Lens shrinks to 120px. Fullscreen buttons shrink to 40px. |
prefers-reduced-motion | All transitions and the spinner animation are disabled. |