Image

The Image component is used to embed images in Halstack-based user interfaces.

Props

NameTypeDescriptionDefault
Required
alt
stringAlternative text description displayed when the specified image is not loaded. See MDN and the alt decision tree of W3C for further information.-
captionstringImage legend with a descriptive purpose. It is placed below the image and is complementary to the alt attribute, which is required regardless of the presence of the caption or not.-
lazyLoadingbooleanIf true, the image will be loaded only when it is visible on the screen (lazy loading). Otherwise and by default, the image will be loaded as soon as the component is mounted (eager loading).false
Required
src
stringURL of the image.-
srcSetstringList of one or more strings separated by commas indicating a set of possible images for the user agent to use. See MDN for further information.-
sizesstringOne or more strings separated by commas, indicating a set of source sizes. If the srcSet attribute is absent or contains no values with a width descriptor, then this attribute has no effect. See MDN for further information.-
widthstringSets the rendered width of the image.-
heightstringSets the rendered height of the image.-
objectFit'contain' | 'cover' | 'fill' | 'none' | 'scale-down'Sets the object-fit CSS property. See MDN for further information.'fill'
objectPositionstringSets the object-position CSS property. See MDN for further information.'50% 50%'
onLoadReact.ReactEventHandler <HTMLImageElement>This function will be called when the image is loaded.-
onErrorReact.ReactEventHandler <HTMLImageElement>This function will be called when the image fails to load.-

Examples

Basic usage