Hello Streamlit Community,
I’ve been working with Streamlit and utilizing tabs for different sections of my application. I encountered a scenario where I wanted to reflect the tab selection in the URL as query parameters automatically when a user switches tabs. This feature would be incredibly useful for maintaining the state of the app and enhancing user experience by allowing direct links to specific tabs.
Currently, it seems that Streamlit does not support modifying the URL to include query parameters based on tab selection directly and automatically. I was wondering if there’s a straightforward method to achieve this behavior within Streamlit’s current capabilities.
Is there a way to customize or extend Streamlit’s default behavior to add query parameters to the URL upon tab clicks? If not, has there been any discussion or plans to incorporate this feature in future releases? Any guidance or workaround to achieve this functionality would be greatly appreciated.
Thank you for your time and help!
query_params = st.query_params.to_dict()
current_tab = query_params.get('tab' , ['1'])[0]
if current_tab == '1':
with tab1:
print("tab1tab1tab1tab1tab1tab1")
su_page_module = importlib.import_module("su_page")
su_page_module.run_sum_main()
if current_tab == '2':
with tab2:
print("tab2tab2tab2tab2tab2tab2")
tr_page_module = importlib.import_module("app_trend_main")
tr_page_module.run_trend_main()