Unfortunately we don’t yet support changing pages programmatically, but feel free to add your thoughts to this related GitHub Issue to help us prioritize this feature enhancement
For anyone landing here, there’s a non-official solution featured in streamlit-extras to switch page inside a multipage app. You can find it here https://extras.streamlit.app/Switch%20page%20function
hey @andfanilo
What if we have to open another streamlit page in same tab?
How can we do that please help me out.
But this doesn’t apply to the button when clicked.
Hi, is there an official solution for opening a new url today? Appreciate the help
So it seems the wonderful @jaypinho has come up with a wonderful solution here. There was another solution provided by the lovely @mathcatsand in the same page - context of in-page streamlit nav links but useful for external links too.
There is also a Link Button on the roadmap for next quarter now.
I found a robust solution which only requires the creation of a button via pure markdown with st.markdown (e.g. green button)
URL_STRING = "https://streamlit.io/"
st.markdown(
f'<a href="{URL_STRING}" style="display: inline-block; padding: 12px 20px; background-color: #4CAF50; color: white; text-align: center; text-decoration: none; font-size: 16px; border-radius: 4px;">Action Text on Button</a>',
unsafe_allow_html=True
)
Very handy and elegant solution.
I’ll use it myself!
Happy Streamlit’in’!
Charly
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
Hey there! There is now a native alternative st.link_button
Read more about it in the docs.