Center an image on the sidebar

I have placed an image on the sidebar however the only way I am able to center it is using the column width option. Is there a way to center the image while being able to adjust the image width instead of relying on the sidebar column width? Thanks.

If I got this correctly, the page’s CSS can be tweaked such that the image width is modified while keeping it centered. Is this the result you’re looking for?


import streamlit as st

        [data-testid=stSidebar] [data-testid=stImage]{
            text-align: center;
            display: block;
            margin-left: auto;
            margin-right: auto;
            width: 100%;
    """, unsafe_allow_html=True

with st.sidebar:
    "# Center an image in the sidebar"
    "This image is centered in the sidebar"

"Behavior of other images stays unaltered"
st.image("", width=100)