Show API reference for

Configure an image column in st.dataframe or st.data_editor.

Image columns display an inline thumbnail. When a user double clicks a thumbnail in a cell, Streamlit displays a larger image. To display an image, a cell must have one of the following values:

  • A URL to fetch the image from. If you use static file serving, the URL can be relative to your app's URL. Otherwise, the URL must be fully qualified with a scheme, like "https://example.com/my_image.jpg".

    Paths to local image files aren't supported.

  • A data URL containing an SVG XML like "data:image/svg+xml;utf8,<svg xmlns=...</svg>".

  • A data URL containing a Base64 encoded image like "data:image/png;base64,iVBO...".

Image columns aren't editable at this time. This command must be used in the column_config parameter of st.dataframe or st.data_editor.

Function signature[source]

st.column_config.ImageColumn(label=None, *, width=None, help=None, pinned=None, alignment=None)

Parameters

label (str or None)

The label shown at the top of the column. If this is None (default), the column name is used.

width ("small", "medium", "large", int, or None)

The display width of the column. If this is None (default), the column will be sized to fit the cell contents. Otherwise, this can be one of the following:

  • "small": 75px wide
  • "medium": 200px wide
  • "large": 400px wide
  • An integer specifying the width in pixels

If the total width of all columns is less than the width of the dataframe, the remaining space will be distributed evenly among all columns.

help (str or None)

A tooltip that gets displayed when hovering over the column label. If this is None (default), no tooltip is displayed.

The tooltip can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the body parameter of st.markdown.

pinned (bool or None)

Whether the column is pinned. A pinned column will stay visible on the left side no matter where the user scrolls. If this is None (default), Streamlit will decide: index columns are pinned, and data columns are not pinned.

alignment ("left", "center", "right", or None)

The horizontal alignment of cell content. If this is None (default), images are center-aligned.

Examples

import pandas as pd
import streamlit as st

data_df = pd.DataFrame(
    {
        "apps": [
            "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/5435b8cb-6c6c-490b-9608-799b543655d3/Home_Page.png",
            "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/ef9a7627-13f2-47e5-8f65-3f69bb38a5c2/Home_Page.png",
            "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/31b99099-8eae-4ff8-aa89-042895ed3843/Home_Page.png",
            "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/6a399b09-241e-4ae7-a31f-7640dc1d181e/Home_Page.png",
        ],
    }
)

st.data_editor(
    data_df,
    column_config={
        "apps": st.column_config.ImageColumn(
            "Preview Image", help="Streamlit app preview screenshots"
        )
    },
    hide_index=True,
)
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.