Collapsible page folders in sidebar

Is it possible to make page categories collapsible in the sidebar UI? I have a multi page app with each page in a category and would like the folders/categories in which the pages are grouped to be collapsible.

For example, I have a page with following page structure below. I would like to be able to click on “Secondary Reports” in the sidebar to hide all the pages within that category, is something like this possible?

pg = st.navigation(
    {
    "Primary Reports": [
        st.Page("_pages/page1.py", title = "Page 1", icon = ":material/manage_search:"),  
        st.Page("_pages/page2.py", title = "Page 2", icon = ":material/manage_search:"),  
        st.Page("_pages/page3.py", title = "Page 3", icon = ":material/manage_search:"),  
        st.Page("_pages/page4.py", title = "Page 4", icon = ":material/manage_search:"),  
        st.Page("_pages/page5.py", title = "Page 5", icon = ":material/manage_search:")
        ],
    "Secondary Reports": [
        st.Page("_pages/page1b.py", title = "Page 1b", icon = ":material/manage_search:"),  
        st.Page("_pages/page2b.py", title = "Page 2b", icon = ":material/manage_search:"),  
        st.Page("_pages/page3b.py", title = "Page 3b", icon = ":material/manage_search:"),  
        st.Page("_pages/page4b.py", title = "Page 4b", icon = ":material/manage_search:"),  
        st.Page("_pages/page5b.py", title = "Page 5b", icon = ":material/manage_search:")
        ],

    }
)

# Executes selected page 
pg.run()

To be precise, I want to mimic this functionality as shown in the Streamlit forum:
Open Section


Closed Section

Our app has grown to have a lot of page so this feature would be really helpful for our users.

Thank you!

Not possible right now but feel free to upvote this GitHub issue: Make sections in navigation menu collapsable · Issue #9551 · streamlit/streamlit · GitHub

1 Like