gabrieltempass / streamlit-navigation-bar

A component that allows you to place a navigation bar in your Streamlit app.
https://streamlit.io/
MIT License
112 stars 11 forks source link

Make it work together with Multipage v2 #22

Closed hagsted closed 2 weeks ago

hagsted commented 1 month ago

Checklist

Summary

I would like to add a navigation bar to the top of my page, but still be able to use the new multipage v2 functionality to have some pages in the sidebar also.

Why?

This would enable me to split pages into groups by type, and still minimize the options in the sidebar so it does not need to collapse.

How?

How I would like to do this would be something like

from streamlit_navigation_bar import st_navbar

page = st_navbar(["Home", "Processes", "Tools"])
home = [
        st.Page(
           page/home.py, title="Welcome", icon=":material/home:", url_path="welcome"
        )
    ]

processes = [
        st.Page(
            page/process1.py,
            title="Process1",
            icon=":material/minimize:",
            url_path="process1"
        ),
        st.Page(
            page/process2.py,
            title="Process2",
            icon=":material/minimize:",
            url_path="process2"
        ),
    ]
tools = [
        st.Page(
            "page/Tools.py", title="Tools", icon=":material/construction:", url_path="tools",
        st.Page(
            "page/About.py", title="About", icon=":material/info:", url_path="about"
        )
    ]

if page == "Home":
    pg = st.navigation(home)
elif page == "Processes":
    pg = st.navigation(processes)
elif page == "Tools":
    pg = st.navigation(tools)

pg.run()

Additional context

No response

hagsted commented 2 weeks ago

Sorry. It does actually work somewhat okay with multipage v2. I do however need a on_change parameter to get it better working with query_params. I will try to make a pull request for that.