<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Zoomable Image

An interactive image wrapper that provides inline zooming and panning for detailed product inspection.
stylekeys: zoomableImage

Use Zoomable Image...

  • When the image contains visual details that matter for decisions and help customers feel confident about their choice or design. For example, checking product texture, small text, logo placement, or intricate artwork.
  • To allow users to examine image details in depth while keeping the surrounding page content visible.

Don’t use Zoomable Image...

  • For small images where detailed inspection provides little or no value.
  • Nested with other zoom or pan behaviors that may conflict with its interaction.
  • Avoid using ZoomableImage on purely decorative imagery, where zooming and panning do not add any real value to the experience.

The preview has been updated.

With Callback

Use onExpandClick when clicking the image should open an extended view of that same image.
This is typically used to open a larger, more detailed view of the image for deeper inspection. For example, in a Lightbox that provides a second level of zoom, or in another focused container dedicated to viewing the image at a larger size, with any supporting details or actions.

The preview has been updated.

Use ZoomableImage inside an Adaptive carousel to provide zoom and pan interactions for the carousel image slides.

The preview has been updated.

With Overlay Element

The preview has been updated.

Control

  • When ZoomableImage is used directly on the page (outside a Lightbox), it provides an inline zoom experience. Hovering the image with a pointer, or pressing the assigned (+ / -) zoom keys when it has keyboard focus, triggers zoom.
  • When ZoomableImage is used inside a Lightbox, clicking the image (with a pointer or via keyboard activation) toggles zoom on and off.
  • Once zoomed (inline or in a Lightbox), moving the pointer or using the arrow keys pans within the zoomed image.
  • On touch devices, users rely on the browser’s native pinch‑to‑zoom and pan, so there’s no additional UI control to enable and no extra implementation required.

Minimum size

  • Avoid using ZoomableImage at widths under 320px. Inspection becomes restricted and sub‑optimal in containers smaller than this threshold. Instead, use a Lightbox, rather than relying on inline zoom.

Props

ZoomableImage
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
onLoad(ReactEventHandler<HTMLDivElement> & ReactEventHandler<HTMLImageElement>)false
Callback triggered when the image successfully loads
null
onError(ReactEventHandler<HTMLDivElement> & ReactEventHandler<HTMLImageElement>)false
Callback triggered when the image fails to load
null
srcstring | undefinedtrue
Source URL for the image
null
srcSetstringfalse
Image sources for different viewport sizes and pixel densities
null
sizesstringfalse
Media query conditions for the srcSet attribute
null
altstringfalse
Accessible label describing the image content
null
onExpandClick(() => void)false
Callback triggered when the image is clicked, to expand/open a larger or more detailed view
null

Internationalization

SWAN's Internationalization System allows SWAN components to render with fully translated and accessible text out-of-the-box. The following keys are provided to allow you to override the default translation.

Default TextKey
Zoomable Image
zoomable-image.accessible-label
Click to expand
zoomable-image.accessible-label-hover-trigger-button
Click to zoom in and zoom out
zoomable-image.accessible-label-click-trigger-button
Zoomed to {{zoomLevel}}
zoomable-image.zoom-to-label
maximum
zoomable-image.zoom-level-max
minimum
zoomable-image.zoom-level-min
Click to zoom in or zoom out and use arrow keys to pan
zoomable-image.click-instruction
Use {{zoomInKey}} and {{zoomOutKey}} key to zoom and arrow keys to pan
zoomable-image.hover-instruction
Use plus and minus key to zoom and arrow keys to pan
Accessible instructions for keyboard users on how to interact with the component
zoomable-image.accessible-text-for-hover-instruction
Use arrow keys to pan
Accessible instructions for keyboard users on how to interact with the component
zoomable-image.accessible-text-for-click-instruction

Related