Skip to Content

ImageViewer

ImageViewer renders an image from an OSDK Media object, and BaseImageViewer renders an image from a URL you provide.

Import

import {
  BaseImageViewer,
  ImageViewer,
} from "@osdk/react-components/image-viewer";
  • ImageViewer — Primary component for OSDK usage. Accepts an OSDK Media object, handles fetching the image contents, and renders via a native <img> element.
  • BaseImageViewer — Lower-level component that accepts a URL string directly. Use this when you already have the image source.

Usage

With OSDK Media

import { ImageViewer } from "@osdk/react-components/image-viewer";

<ImageViewer media={product.photo} alt="Product photo" />;

With a URL

import { BaseImageViewer } from "@osdk/react-components/image-viewer";

<BaseImageViewer src="https://example.com/photo.png" alt="Example" />;

Props

BaseImageViewerProps

PropTypeRequiredDescription
srcstringYesObject URL or data URL for the image
altstringNoAlt text for accessibility
classNamestringNoCSS class applied to the root element
onError() => voidNoCallback when the image fails to load

ImageViewerProps

PropTypeRequiredDescription
mediaMediaYesThe OSDK Media object to fetch image from
altstringNoAlt text for accessibility
classNamestringNoCSS class applied to the root element
onError() => voidNoCallback when the image fails to load

Supported formats

PNG, JPEG, GIF, SVG, WebP, and BMP — any format supported by the browser's native <img> element.

Theming

:root {
  --osdk-image-viewer-bg: var(--osdk-background-primary);
  --osdk-image-viewer-border: var(--osdk-surface-border);
}

On this page