v1.6.x-dev NDS IQ v6

Image Popup Viewer - National Design System

A full-screen image viewer for inspecting photos and illustrations with zoom, pan, and gallery navigation

Image Gallery

Click any thumbnail to open the full-screen viewer with zoom and navigation controls

Built-in Features

What you get out of the box with zero configuration

Auto-initialization

Any image with the nds-ipv-thumbnail class becomes clickable and opens in the full-screen viewer. No extra markup or JS calls needed. For dynamically added images, call NDS.Ipv.init().

Multi-input Zoom

Zoom into images using mouse wheel (centered on cursor position), keyboard shortcuts (+/-), pinch-to-zoom on touch devices, or the on-screen zoom buttons. Supports 0.1x to 10x magnification.

Drag to Pan

Click and drag on desktop or swipe on touch devices to pan around zoomed images. Double-click or double-tap resets the view to the original position and zoom level.

Gallery Navigation

Every thumbnail on the page joins one navigable gallery. Arrow buttons and the left/right keys move between images, and a counter shows the current position. Controls hide automatically when a page has only one image.

Keyboard Controls

Thumbnails are reachable with Tab and open with Enter or Space. Inside the viewer, Escape closes, +/- adjusts zoom, 0 resets the view, H toggles the controls, and arrow keys move between images.

Touch Gestures

Pinch-to-zoom with two fingers centers on the gesture midpoint. Single-finger drag pans the image. All gestures work alongside on-screen controls on mobile.

Distraction-free Mode

Press H or tap the toggle button to hide all controls, navigation, and overlays for a clean viewing experience. Toggle again to restore the full UI.

Adaptive Image Loading

Thumbnails load at a small size for fast page rendering, then the full-resolution image loads on demand when opened. A loading spinner displays while the full image is fetched.

Accessible Dialog

The viewer opens as a focus-trapped dialog: keyboard focus stays within it while open, and returns to the thumbnail you opened it from when it closes.

Localized Controls

Control labels and on-screen instructions follow the page language automatically, with Arabic and English provided out of the box.

Usage Guidelines

When and how to use the image popup viewer effectively

Best Practices

  • Use the image popup viewer for any content where users need to inspect image details: product photos, maps, infographics, architectural plans, or document scans. The zoom and pan controls let users explore at their own pace.
  • Every nds-ipv-thumbnail on a page joins one shared gallery: opening any image lets users move through the rest with the arrow keys or on-screen buttons. Keep related images on the same page so navigation feels coherent.
  • Navigation controls appear only when a page has more than one thumbnail. For a single standalone image, the viewer opens with zoom and pan but no prev/next controls.
  • Do not use the image popup viewer for decorative or background images that don't benefit from close inspection. Only apply it to images where zoom and detail matter to the user.
  • Do not use this component for modal dialogs with mixed content. Use Modal instead when you need text, forms, or actions alongside an image.
  • Always provide a data-ipv-full attribute pointing to a high-resolution version of the image. Without it, the viewer falls back to the thumbnail src, which may look blurry when zoomed.
  • Keep thumbnail images small (400px wide) for fast page load. The full-resolution image loads on demand only when the user opens the viewer.
  • Write descriptive alt text on every thumbnail. The viewer reuses it for the full-size image, and it doubles as the accessible name when users reach the thumbnail by keyboard.
  • Thumbnails are keyboard-operable out of the box: Tab focuses them, Enter or Space opens the viewer, and focus returns to the thumbnail on close. Avoid adding custom click-only handlers that bypass this.
  • Add nds-ipv-image-title below thumbnails in galleries to give users context before they open the viewer.

Modifier Classes

ClassDescription
nds-ipv-thumbnailRequired on the <img> that opens the viewer.
nds-ipv-galleryOptional grid wrapper for image items. Combine with nds-grid and the --max-col / --mid-col / --min-col variables to set columns.
nds-ipv-image-itemOptional grid cell grouping an image card with its caption below.
nds-ipv-image-cardOptional frame around the thumbnail; hosts the showZoom badge.
nds-ipv-image-titleOptional caption placed below the image card.
showZoomAdd to nds-ipv-image-card to display a zoom-affordance badge in the corner of the thumbnail.

Data Attributes

AttributeDescription
data-ipv-fullSet on the thumbnail <img> to specify the full-resolution image URL loaded when the viewer opens.
data-srcFallback full-size source used when data-ipv-full is absent (supports lazy-loading setups). The thumbnail's own src is the final fallback.

JavaScript API

The NDS.Ipv API controls initialization and programmatic access. The viewer auto-initializes on page load. For dynamically added thumbnails, call NDS.Ipv.init() or NDS.Ipv.reinit() to re-scan the page.

// ── Initialization ────────────────────────────────── // All thumbnails auto-initialize on page load NDS.Ipv.init(); // Re-initialize after dynamically adding thumbnails NDS.Ipv.reinit(); // Create and get the viewer instance var viewer = NDS.Ipv.create(); // Access the existing instance directly var viewer = window.ndsIPV; // ── Instance Methods ──────────────────────────────── // Open the viewer for a specific thumbnail element viewer.open(thumbnailElement); // Close the viewer viewer.close(); // Navigate between images in a gallery viewer.showPrev(); viewer.showNext(); // Reset zoom and pan to defaults viewer.resetTransform(); // Toggle UI controls visibility (distraction-free mode) viewer.toggleUI(); // Tear down all listeners, resize observer, and focus trap viewer.destroy(); // ── Keyboard Shortcuts ────────────────────────────── // Tab Move focus to a thumbnail, then Enter or Space opens it // Escape Close the viewer (focus returns to the thumbnail) // + or = Zoom in (1.5x per press) // - Zoom out (1.5x per press) // 0 Reset zoom and position // H Toggle UI visibility // ArrowLeft Previous image in gallery // ArrowRight Next image in gallery // Tab is trapped within the viewer while it is open
Last Modified Date: 28/06/2026 - 01:27 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks