Image

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

Props

NameDefaultDescription
alt: stringAlternative text description displayed when the specified image is not loaded. See MDN and the alt decision tree of W3C for further information. This prop is required.
caption: stringImage 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.
lazyLoading: booleanfalseIf 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).
src: stringURL of the image. This prop is required and must be valid.
srcSet: stringList 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.
sizes: stringOne 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.
width: stringSets the rendered width of the image.
height: stringSets the rendered height of the image.
objectFit: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down''fill'Sets the object-fit CSS property. See MDN for further information.
objectPosition: string'50% 50%'Sets the object-position CSS property. See MDN for further information.
onLoad: ReactEventHandlerThis function will be called when the image is loaded.
onError: ReactEventHandlerThis function will be called when the image fails to load.

Examples

Basic usage