I have a multipage app where the navigation is accomplished with buttons using the st_pages component. Since I have no need for the sidebar, I want to remove it. But I haven’t been able to do it properly.
I’ve created a minimal example that ilustrates my issue:
Code snippet:
import streamlit as st
from st_pages import Page, show_pages
st.set_page_config('Hello Forum',initial_sidebar_state='collapsed')
show_pages(
[
Page('page_1.py', 'Page 1'),
Page('page_2.py', 'Page 2'),
]
)
st.markdown("""
<style>
[data-testid="stSidebar"] {
display: none
}
[data-testid="collapsedControl"] {
display: none
}
</style>
""", unsafe_allow_html=True)
(You can reproduce it by copying this code in a “page_1.py” file and having some other “page_2.py” file in the same folder)
Expected behavior:
I want one of two things, either:
- having the “collapsed” initial_sidebar_state be instant (and not play the closing animation when loading a page)
or
- Instantly hide the sidebar using css
Actual behavior:
As of right now, if I just set the initial state of the sidebar as “collapsed” it shows the sidebar closing each time a page loads, which is very distracting for the user
If I try to hide the sidebar using css (regardless of the initial stat being “collapsed” os “expanded”, the sidebar still displays for a few miliseconds before actually disapearing, which is again very undesirable for user experience.
¿Does anyone know how to approach this differently or how to make my approaches work?