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
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:
st.set_page_config(initial_sidebar_state="collapsed")
If you would like to hide the sidebar button too, you could make a CSS adjustment with :
st.markdown(
"""
<style>
div[data-testid="collapsedControl"] {
visibility: hidden;
}
</style>
""",
unsafe_allow_html=True
)
I hope that helps! Otherwise, please provide more details about your issueā¦
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.
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)
The problem has been solved. The official method is to configure it in config.toml. Thank you for your answers.
[client].
ShowSidebarNavigation = false