Skip to content

Cover Image

CoverImage renders images that fill a container - the container dictates the dimensions and the image stretches and crops to cover it with object-fit: cover applied by default. Think of it as the accessible, SEO-friendly replacement for background-image: cover.

Use CoverImage when the image is a backdrop: hero banners, card backgrounds, split-layout panels, full-bleed sections, or anywhere a fixed-size container needs an image filling it edge to edge.

Aerial cityscape used as a hero banner background

Hero Banner

The container controls the size - the image stretches and crops to fill it.

Art-directed cover images use <picture> with multiple sources for different breakpoints. Each source can provide a different crop or aspect ratio suited to the viewport.

Art-directed cover image

Hero Banner

The container controls the size - the image stretches and crops to fill it.

Override the default object-position: center when the focal point of the image is off-center. This example shows top-right positioning.

Cover image with custom object-position - the focal point is offset toward the top-right

Hero Banner

The container controls the size - the image stretches and crops to fill it.

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.

Cover image with a CMS-provided srcSet override

Hero Banner

The container controls the size - the image stretches and crops to fill it.

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.

Hero Banner

The container controls the size - the image stretches and crops to fill it.

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

Cover image without explicit dimensions

Hero Banner

The container controls the size - the image stretches and crops to fill it.

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.

Cover image with a profile missing sizes

Hero Banner

The container controls the size - the image stretches and crops to fill it.

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

import { CoverImage } from "@/rokkit200-ui/components/cover-image/cover-image";
{/* Hero banner - the container controls the size, image fills it */}
<div className="relative h-96 w-full">
<CoverImage
imageSource={{
src: "/photos/hero-banner.jpg",
width: 1200,
height: 600,
metadata: { alt: "Hero banner" },
}}
profile={{
id: "hero",
srcSetWidths: [600, 900, 1200],
sizes: ["100vw"],
}}
/>
<div className="relative z-10 p-8">
<h1>Your heading over the cover image</h1>
</div>
</div>
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 cover images. Optional.
urlBuilderImageUrlBuilderpassthroughCDN-specific URL builder. Optional.
objectPositionClassNamestring"object-center"CSS object-position applied to the <img>. Shift the crop focal point away from center. 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). Composed with object-cover by default. 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.