How to align the image within its bounds. It maps to css `object-position` property.
Image
The Image component is used to display images with support for fallback.
Props#
align
alignResponsiveValue<ObjectPosition<Length>>crossOrigin
crossOriginThe key used to set the crossOrigin on the HTMLImageElement into which the image will be loaded. This tells the browser to request cross-origin access when trying to download the image data.
"" | "anonymous" | "use-credentials"fallback
fallbackFallback element to show if image is loading or image fails.
ReactElement<any, string | JSXElementConstructor<any>>fallbackSrc
fallbackSrcFallback image src to show if image is loading or image fails.
Note 🚨: We recommend you use a local image
stringfallbackStrategy
fallbackStrategy- beforeLoadOrError(default): loads the fallbackImage while loading the src - onError: loads the fallbackImage only if there is an error fetching the src
FallbackStrategybeforeLoadOrErrorfit
fitHow the image to fit within its bounds. It maps to css `object-fit` property.
ResponsiveValue<ObjectFit>htmlHeight
htmlHeightThe native HTML height attribute to the passed to the img
string | numberhtmlWidth
htmlWidthThe native HTML width attribute to the passed to the img
string | numberignoreFallback
ignoreFallbackIf true, opt out of the fallbackSrc logic and use as img
booleanfalseloading
loading"eager" | "lazy"onError
onErrorA callback for when there was an error loading the image src
ReactEventHandler<HTMLImageElement>onLoad
onLoadA callback for when the image src has been loaded
ReactEventHandler<HTMLImageElement>sizes
sizesThe image sizes attribute
stringsrc
srcThe image src attribute
stringsrcSet
srcSetThe image srcset attribute
stringProps#
align
alignHow to align the image within its bounds. It maps to css `object-position` property.
ResponsiveValue<ObjectPosition<Length>>crossOrigin
crossOriginThe key used to set the crossOrigin on the HTMLImageElement into which the image will be loaded. This tells the browser to request cross-origin access when trying to download the image data.
"" | "anonymous" | "use-credentials"fallback
fallbackFallback element to show if image is loading or image fails.
ReactElement<any, string | JSXElementConstructor<any>>fallbackSrc
fallbackSrcFallback image src to show if image is loading or image fails.
Note 🚨: We recommend you use a local image
stringfallbackStrategy
fallbackStrategy- beforeLoadOrError(default): loads the fallbackImage while loading the src - onError: loads the fallbackImage only if there is an error fetching the src
FallbackStrategybeforeLoadOrErrorfit
fitHow the image to fit within its bounds. It maps to css `object-fit` property.
ResponsiveValue<ObjectFit>htmlHeight
htmlHeightThe native HTML height attribute to the passed to the img
string | numberhtmlWidth
htmlWidthThe native HTML width attribute to the passed to the img
string | numberignoreFallback
ignoreFallbackIf true, opt out of the fallbackSrc logic and use as img
booleanfalseloading
loading"eager" | "lazy"onError
onErrorA callback for when there was an error loading the image src
ReactEventHandler<HTMLImageElement>onLoad
onLoadA callback for when the image src has been loaded
ReactEventHandler<HTMLImageElement>sizes
sizesThe image sizes attribute
stringsrc
srcThe image src attribute
stringsrcSet
srcSetThe image srcset attribute
string