Redirecting to a different page without the sidebar

Can I somehow redirect the user to a different page in the same app, without getting a new session ?
Iā€™ve been searching for a solution like this for quite a lot of time, but couldnā€™t find a solution that fits this case

1 Like

Thereā€™s an add-on for that:

1 Like

Yeah this works well, i knew about this add-on before, but this is only possible with the use of the sidebar, right ?
I was curious if there is a way to do this but without the sidebar

Oops. I meant to link to streamlit-extras. There is a switch page function. @blackary makes a lot of useful thingsā€¦

5 Likes

Nice, thank you for your help

Iā€™m looking for something very similar ā€“ moving to a different page of a multi page app ā€“ but Iā€™d like to do this with link in markdown text, like ā€œā€¦and go here to do Xā€¦ā€

Does anybody know if thatā€™s possible?

HTML style <a> with target=_self doesnā€™t work as it opens a new session.

Try this instead:

st.markdown('<a href="/foo" target=_top>Another Page</a>', unsafe_allow_html=True)

Doesnā€™t work for me, unfortunately! I still get a new session.

try this:
<a href="/foo" target="_self">Another Page</a>

There is still a sidebar, we need to get rid of that and still do the redirection

If you are just wanting to hide the sidebar because you are using switch_page from streamlit-extras instead for all navigation, you can hide the sidebar with CSS:

Hide the entire sidebar:

css ='''
<style>
    [data-testid="stSidebar"] {
        display: none;
    }
</style>
'''
st.markdown(css, unsafe_allow_html=True)

Alternatively, just hide the navigation part:

css ='''
<style>
    [data-testid="stSidebarNav"] {
        display: none;
    }
</style>
'''
st.markdown(css, unsafe_allow_html=True)
1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.