Image
An Img tag with a more Silk-like API.
Parameters
The width, in pixels, of the image. If not specified, the image will be displayed at its natural size. However, it's better to specify the width and height if known so that the browser can reserve the space for the image.
See docs for width, except this applies to the height of the image in pixels.
An optional description which gets used as alt text for the image. This is useful to include for accessibility tools.
Convenience version of Image
where the alt description is not optional.
We provide this convenience method since it is strongly encouraged to include a description with your images for accessibility reasons.
Note that the parameter here is called description
instead of alt
to avoid ambiguity issues with the other Image
method. In other words, because of this decision, you can write this code:
Image(
"/my-image.png",
alt = "My image description",
modifier = Modifier.stuff()
and the compiler won't complain about getting confused between which method you're trying to call.