Skip to content

Content Image

ContentImage renders images that participate in document flow - the image controls its own dimensions and pushes surrounding content out of the way, just like a paragraph or heading. No object-fit styling is applied; the image renders at its natural aspect ratio.

Use ContentImage when the image is the content: article photos, product shots, thumbnails, inline figures, or any image whose intrinsic size matters to the layout.

The image below flows naturally within the article body. It renders at its intrinsic aspect ratio and the surrounding text wraps around it - the image controls its own size.

Photograph of a mountain landscape used as an inline content image

This is a ContentImage - use it when the image is the content: article photos, product shots, thumbnails, or any image that participates in document flow.

Art-directed content images use <picture> with multiple sources. The imageClassName prop targets the inner <img> element while className applies to the <picture> wrapper. For more on Art Directed images and the <picture> element, see here.

Art-directed content image

Bypass the planner-generated srcset with a pre-built string (e.g. from a CMS). Width descriptors are validated against resolvable sizes - if sizes cannot be resolved, the override is discarded with a dev warning.

Content image with a CMS-provided srcSet override

A non-decorative image with no alt text triggers a dev warning. Either provide an alt prop, populate metadata.alt on the source, or mark the image as decorative.

An image without width / height triggers a dev warning. Pass suppressMissingDimensionsWarning for intentionally dimension-free images such as SVGs or data URIs.

Image without explicit dimensions

A profile with srcSetWidths but no sizes causes the planner to discard the generated srcset and emit a dev warning. Provide sizes on the profile or via the sizes prop.

Image with a profile missing sizes

Below is an example of how to use ContentImage in your site.

import { ContentImage } from "@/rokkit200-ui/components/content-image/content-image";
{/* Inline image in an article - the image controls its own size */}
<ContentImage
imageSource={{
src: "/photos/article-photo.jpg",
width: 800,
height: 500,
metadata: { alt: "Article photo" },
}}
profile={{
id: "content",
srcSetWidths: [400, 600, 800],
sizes: ["(max-width: 600px) 100vw", "800px"],
}}
/>
PropTypeDefaultDescription
imageSourceNormalizedImageSourceThe image data object (src, width, height, metadata). Required (XOR with art-directed props).
profilePictureProfileResponsive profile controlling srcset widths, sizes, format, quality, and fit. Required with imageSource.
sizesstringOverride sizes from the profile for this specific instance. Optional.
PropTypeDefaultDescription
artDirectedImageSourceArtDirectedImageSource<K>Fallback image plus breakpoint-specific sources for <picture> rendering. Required (XOR with normalized props).
profileMapRecord<K, PictureProfile>Map of profile keys to profiles, one per source entry. Required with artDirectedImageSource.
PropTypeDefaultDescription
altstringOverride alt text. Falls back to imageSource.metadata.alt. Optional.
decorativebooleanfalseMark as decorative (renders alt=""). Optional.
loading"lazy" | "eager""lazy"HTML loading strategy. Optional.
fetchPriority"high" | "low" | "auto"Fetch priority hint for the browser. Optional.
decoding"async" | "sync" | "auto""async"Decoding strategy. Defaults to async for content images. Optional.
urlBuilderImageUrlBuilderpassthroughCDN-specific URL builder. Optional.
classNamestringApplied to the outermost element (<img> or <picture>). Optional.
styleReact.CSSPropertiesInline styles on the outermost element. Optional.
imageClassNamestringApplied to the <img> inside <picture> (art-directed only). Optional.
imageStyleReact.CSSPropertiesInline styles on the <img> inside <picture>. Optional.
srcSetOverridestringBypass planner-generated srcset with a pre-built string. Width descriptors require resolvable sizes or the override is discarded. Optional.
suppressWarningsbooleanfalseSilence all dev warnings. Optional.
suppressMissingDimensionsWarningbooleanfalseSilence the missing-dimensions warning only. Optional.
suppressMissingSizesWarningbooleanfalseSilence the missing-sizes warning only. Optional.
suppressEmptyAltWarningbooleanfalseSilence the empty-alt warning only. Optional.