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
There’s an add-on for that:
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…
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)