Skip to content

Image

Overview

Image is the equivalent of an <img> HTML element.

Examples

import mesop as me


@me.page(
  security_policy=me.SecurityPolicy(
    allowed_iframe_parents=["https://google.github.io"]
  ),
  path="/image",
)
def app():
  me.image(
    src="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
    alt="Grapefruit",
    style=me.Style(width="100%"),
  )

API

image

This function creates an image component.

PARAMETER DESCRIPTION
src

The source URL of the image.

TYPE: str | None DEFAULT: None

alt

The alternative text for the image if it cannot be displayed.

TYPE: str | None DEFAULT: None

style

The style to apply to the image, such as width and height.

TYPE: Style | None DEFAULT: None

key

The component key.

TYPE: str | None DEFAULT: None