Streamlit_qs: Make Permalinks and Take Names [Query String Utils]

:fire_engine: Skip all this and go straight to the example: https://query-string.streamlit.app/ :fire_engine:

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:

  1. 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.
  2. 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.

3 Likes

Package has been updated to support Streamlit 1.27.0+ with it’s new “None” values in widgets. Check out the release today: Release v0.2.0 · Asaurus1/streamlit-qs · GitHub

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.