Skip to main content
Version: v9

ion-img

shadow

Img is a tag that will lazily load an image whenever the tag is in the viewport. This is extremely useful when generating a large list as images are only loaded when they're visible. The component uses Intersection Observer internally, which is supported in most modern browsers, but falls back to a setTimeout when it is not supported.

Basic Usage

Properties

alt

DescriptionThis attribute defines the alternative text describing the image. Users will see this text displayed if the image URL is wrong, the image is not in one of the supported formats, or if the image is not yet downloaded.
Attributealt
Typestring | undefined
Defaultundefined

mode

DescriptionThe mode determines the platform behaviors of the component.

This is a virtual property that is set once during initialization and will not update if you change its value after the initial render.
Attributemode
Type"ios" | "md"
Defaultundefined

src

DescriptionThe image URL. This attribute is mandatory for the <img> element.
Attributesrc
Typestring | undefined
Defaultundefined

theme

DescriptionThe theme determines the visual appearance of the component.

This is a virtual property that is set once during initialization and will not update if you change its value after the initial render.
Attributetheme
Type"ios" | "md" | "ionic"
Defaultundefined

Events

NameDescriptionBubbles
ionErrorEmitted when the img fails to loadtrue
ionImgDidLoadEmitted when the image has finished loadingtrue
ionImgWillLoadEmitted when the img src has been settrue

Methods

No public methods available for this component.

CSS Shadow Parts

NameDescription
imageThe inner img element.

CSS Custom Properties

No CSS custom properties available for this component.

Slots

No slots available for this component.