Skip to content

Image

Responsive image with lazy loading, async decoding, and an error fallback. Reserve layout space with native dimensions, wrapper sizing, or `AspectRatio`.

Mountain landscape at sunset
<Image
alt="Mountain landscape at sunset"
height={800}
src={landscapeSource}
style={{maxWidth: 720}}
width={1200}
/>
Mountain landscape at sunset
<Image
alt="Mountain landscape at sunset"
height={800}
src={landscapeSource}
style={{maxWidth: 720}}
width={1200}
sizes="(max-width: 640px) 100vw, 720px"
srcSet="https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=480&auto=format&fit=crop 480w, https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=960&auto=format&fit=crop 960w, https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=1440&auto=format&fit=crop 1440w"
/>

cover

Landscape cropped to cover

contain

Full landscape contained in frame
<div
style={{
display: 'grid',
gap: 16,
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
maxWidth: 720,
}}>
<div>
<p>cover</p>
<AspectRatio ratio={1}>
<Image alt="Landscape cropped to cover" src={landscapeSource} />
</AspectRatio>
</div>
<div>
<p>contain</p>
<AspectRatio ratio={1}>
<Image
alt="Full landscape contained in frame"
objectFit="contain"
src={landscapeSource}
/>
</AspectRatio>
</div>
</div>
Unavailable product photo
<Image
alt="Unavailable product photo"
height={400}
src="/missing-image.jpg"
style={{height: 240, width: 360}}
width={600}
fallback={<span>Product image unavailable</span>}
/>
Mountain landscape hero
<div style={{maxWidth: 960}}>
<AspectRatio ratio={16 / 9}>
<Image
alt="Mountain landscape hero"
fetchPriority="high"
loading="eager"
src={landscapeSource}
/>
</AspectRatio>
</div>

Responsive image with lazy loading, async decoding, and an error fallback. Reserve layout space with native dimensions, wrapper sizing, or `AspectRatio`.

PropTypeDefaultDescription
alt*stringAlternative text describing the image. Use an empty string for a decorative image.
classNamestringAdditional CSS class names applied to the wrapper.
data-testidstringTest ID applied to the wrapper.
decodingComponentPropsWithoutRef<'img'>['decoding']'async'Browser decoding hint.
fallbackReactNodeContent displayed if the image fails to load. Defaults to a muted image placeholder.
loadingComponentPropsWithoutRef<'img'>['loading']'lazy'Browser loading strategy.
objectFit"fill" | "none" | "contain" | "cover" | "scale-down"'cover'How the image is resized within its frame.
refRef<HTMLDivElement>Ref forwarded to the stable wrapper element.
sizesstringResponsive source-size hints.
src*stringImage source.
srcSetstringResponsive image sources.
styleCSSPropertiesInline styles applied to the wrapper.