Skip all this and go straight to the example: https://query-string.streamlit.app/
streamlit_qs
is an add-on library that extends the functionality existing streamlit input elements to easily read and write data to-and-from the URL query string. This makes it easy to do two things:
- Generate a “permalink” for users that captures the “state” of your application and can return them to that same state at a later time, or shared with others.
- Feed data directly to your streamlit app from other applications by encoding it in a JSON string or a compressed base64 string.
This library is currently under development and I would appreciate any feedback or feature requests.
So what does it look like?
Reading data from the URL
import streamlit_qs as stqs
stqs.text_input_qs("Enter Some Text", key="input_some_text")
# Nagivating to https://your.streamlit.app/?input_some_text=Hello+World
# will populate the text box with "Hello World"
Writing data to the URL
import streamlit_qs as stqs
stqs.text_input_qs("Enter Some Text", key="input_some_text", autoupdate=True)
# Now when you type "Ok, I input some text" into the text_input box,
# the page URL updates to
# https://your.streamlit.app/?input_some_text=Ok%2C+I+input+some+text
It’s not just text input
streamlit_qs
supports most of the standard input elements, and comes with functions
to easily extend your own custom elements with query-string interaction.
selectbox_qs
multiselect_qs
radio_qs
text_area_qs
text_input_qs
number_input_qs
checkbox_qs
- (
slider_qs
coming soon)
A note about the experimental API
Query string interaction within Streamlit is currently experimental, and the API is subject to change at any time. This library works with v1.23.1 of Streamlit but may not be forward compatible with future versions when the experimental query string API is either A) removed, B) made standard, or C) modified in some incompatible way.Please submit an issue if you encounter compatibility issues with future versions of Streamlit.