close the sidebar

I want to close the sidebar, actually there is no way to use css improvement, but after css improvement refresh will see the sidebar, but I do not want to see the sidebar when refreshed

1 Like

Iโ€™m not sure I understood your problem. Do you want to always hide the sidebar?

If that is the case, have you tried using the st.set_page_config at the top of your Streamlit app script? Like so:


If you would like to hide the sidebar button too, you could make a CSS adjustment with :

        div[data-testid="collapsedControl"] {
            visibility: hidden;

I hope that helps! Otherwise, please provide more details about your issueโ€ฆ

1 Like

I am assuming you are using st.markdown. To make changes permanent, best to use javascript via Components API - Streamlit Docs where you add changes to a <style></style>. When app is refreshed, it wonโ€™t flash from streamlit format to your new format.

1 Like

Just include the following line of code to hide the sidebar:
st.markdown(โ€œ [data-testid=โ€˜stSidebarโ€™][aria-expanded=โ€˜trueโ€™]{displace: none; } โ€, unsafe_allow_html=True)

1 Like

The problem has been solved. The official method is to configure it in config.toml. Thank you for your answers.

ShowSidebarNavigation = false