St.navigation menu is forced to the top of the sidebar!

The following is the documentation example from the st.navigation:

import streamlit as st

def page1():
    st.write(st.session_state.foo)

def page2():
    st.write(st.session_state.bar)

# Widgets shared by all the pages
st.sidebar.selectbox("Foo", ["A", "B", "C"], key="foo")
st.sidebar.checkbox("Bar", key="bar")

pg = st.navigation([page1, page2])
pg.run()

You can see that despite the fact that selectbox and checkbox are called before the st.navigation and pg.run they still display below the menu.

How can we control the order of appearance?

st.navigation() will always be at the top of the sidebar.
If you want it to display below some elements, you’ll have to hide it position = "hidden" and use st.page_link() instead

1 Like

Can you provide a code sample?

st.page_link - Streamlit Docs

1 Like