Image

@Composable
fun Image(src: String, modifier: Modifier = Modifier, variant: CssStyleVariant<ImageKind>? = null, width: Int? = null, height: Int? = null, alt: String = "", ref: ElementRefScope<HTMLImageElement>? = null)(source)

An Img tag with a more Silk-like API.

Parameters

width

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.

height

See docs for width, except this applies to the height of the image in pixels.

alt

An optional description which gets used as alt text for the image. This is useful to include for accessibility tools.


@Composable
fun Image(src: String, description: String, modifier: Modifier = Modifier, variant: CssStyleVariant<ImageKind>? = null, width: Int? = null, height: Int? = null, ref: ElementRefScope<HTMLImageElement>? = null)(source)

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.