Skip to content

st.image in st.container with horizontal_alignment is always left-aligned #12435

@jrieke

Description

@jrieke

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

When using st.image in an st.container with horizontal_alignment="center" or horizontal_alignment="right", the image is always left-aligned.

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st

with st.container(horizontal_alignment="center"):
    st.image("https://static.streamlit.io/examples/dice.jpg")
    st.button("Details")

Steps To Reproduce

Run the app.

Expected Behavior

Image is center-aligned.

Current Behavior

Image is left-aligned. Note that the button is correctly center-aligned. This also persists for all different values of width on st.image.

Image

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.49
  • Python version:
  • Operating System:
  • Browser:

Additional Information

No response

Metadata

Metadata

Assignees

Labels

area:layoutRelated to layout and positioningfeature:st.containerRelated to the `st.container` elementfeature:st.imageRelated to the `st.image` elementpriority:P2Medium-high priority - fix within one monthstatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions