Can not set page width in streamlit 1.5.0?

Hi:
I use the max_width() function to set page width and it worked. But after I update to streamlit 1.4 or 1.5, this code does not work properly.
Thanks.
Dave

1 Like

Same here!
Is this a bug or did the parameter name change?
Best,
LeChuck

It’s important to realize that the linked code is CSS, which is dynamically created by React inside of Streamlit. So it’s not guaranteed to be stable across versions of Streamlit or even within runs.

So if it stopped working, it’s likely that one or more of .reportview-container .main .block-container is now different.

def _max_width_():
    max_width_str = f"max-width: 2000px;"
    st.markdown(
        f"""
    <style>
    .reportview-container .main .block-container{{
        {max_width_str}
    }}
    </style>    
    """,
        unsafe_allow_html=True,
    )

Best,
Randy

1 Like

Does streamlit pretend to add a way to change the page width in the future? Because the current st.set_page_config(layout='wide || centered') is not useful, cause wide is too wide, especially with wider displays, and the centered one is too tight. So having another sizes (maybe just a max-width) would be perfect.

css='''
<style>
    section.main > div {max-width:75rem}
</style>
'''
st.markdown(css, unsafe_allow_html=True)

:smiling_face:

2 Likes

Thank you!!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.