Skip to Content

Image usage

Load Rixl images by ID in React and configure layout, alt text, loading callbacks, and analytics.

Connect before mounting media, as shown in Installation.

import {Image} from "@rixl/media-react/image";

export function HeroImage() {
  return (
    <Image
      id="YOUR_IMAGE_ID"
      alt="Mountain lake at sunrise"
      style={{display: "block", width: "100%", aspectRatio: "16 / 9"}}
      onLoadingChange={(loading) => console.log("Loading:", loading)}
      onRixlAnalytics={(event) => console.log(event.detail.event)}
    />
  );
}

id selects the Rixl image. Production components fetch through the SDK; supplied imageData does not replace that request.

Galleries

Render one component per media ID and provide dimensions for each host:

import {Image} from "@rixl/media-react/image";

export function Gallery({images}: {images: {id: string; alt: string}[]}) {
  return (
    <div style={{display: "grid", gridTemplateColumns: "repeat(2, minmax(0, 1fr))", gap: "1rem"}}>
      {images.map((image) => (
        <Image key={image.id} id={image.id} alt={image.alt} style={{display: "block", width: "100%", aspectRatio: "1"}} />
      ))}
    </div>
  );
}

Styling

Use the host for spacing, dimensions, border radius, and clipping. Internal image styles live in shadow DOM. An object-cover class on the host does not change the inner image's fit mode.

Use meaningful alt text for content images. The file name is only a fallback.

See Image props for the typed contract.

On this page