arnaudmiribel / streamlit-extras

Discover, try, install and share Streamlit re-usable bits we call "extras"!
https://extras.streamlit.app
Apache License 2.0
754 stars 126 forks source link

Passing args in the switch_page function #71

Closed LorenzoVela closed 1 year ago

LorenzoVela commented 1 year ago

Hi all,

Is there a way to pass an argument with the switch_page function? Given the fact that the function can't be inserted in the "on-click" parameter of a button it would be quite useful to have the possibility to pass some arguments. Could be this a possible ER? Or is there already a way to perform this action?

Thank you Regards, Lorenzo

blackary commented 1 year ago

Hi @LorenzoVela,

Unfortunately, callbacks don't seem to work for this function, but you should be able to use a button to trigger this function in this way:

import streamlit as st
from streamlit_extras.switch_page_button import switch_page

if st.button("Click me"):
    switch_page("page1")