React image component
Display Rixl images in React with lazy loading, ThumbHash placeholders, alt text, and analytics.
Image resolves a Rixl image ID and displays the returned asset with native lazy loading and a ThumbHash placeholder when one is available.
import {Image} from "@rixl/media-react/image";
export function Cover() {
return <Image id="YOUR_IMAGE_ID" alt="Mountain lake at sunrise" style={{display: "block", width: "100%", aspectRatio: "16 / 9"}} />;
}Connect the SDK before mounting the component. See Installation.
Behavior
- Fetches media by ID through the SDK.
- Uses the returned file URL and image dimensions.
- Shows a placeholder when ThumbHash data is available.
- Emits loading-state callbacks and supports image analytics configuration.
- Includes image styles inside shadow DOM.
The component uses the returned asset; it does not expose a responsive srcset, client-selected format negotiation, or image transformation parameters.
Layout and accessibility
Set the host's dimensions or aspect ratio and provide meaningful alt text. className and style affect the host; they do not set the internal image's object-fit.
React SSR can render the host and children. The internal image renders in the browser, so render essential page metadata in your application when it needs to be in the initial HTML.