shiny.ui.output_image(id, width='100%', height='400px', inline=False)#

Create a output container for a static image.

  • id (str) – An input id.

  • width (str) – The CSS width, e.g. ‘400px’, or ‘100%’

  • height (str) – The CSS height, e.g. ‘100%’ or ‘600px’

  • inline (bool) – If True, the result is displayed inline

Return type

A UI element

See also

image, output_plot


#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
from shiny import *
from shiny.types import ImgData

app_ui = ui.page_fluid(ui.output_image("image"))

def server(input: Inputs, output: Outputs, session: Session):
    def image():
        from pathlib import Path

        dir = Path(__file__).resolve().parent
        img: ImgData = {"src": str(dir / "rstudio-logo.png"), "width": "150px"}
        return img

app = App(app_ui, server)