Using the Streamlit sidebar
As we have already seen in Streamlit, when we start to both accept large amounts of user input and also start to develop longer Streamlit apps, we often lose the ability for the user to see both their input and the output on the same screen. In other cases, we may want to put all the user input into its own section to clearly separate input and output in our Streamlit app. For both of these use cases, we can use the Streamlit sidebar, which allows us to place a minimizable sidebar on the left side of the Streamlit app and add any Streamlit component to it.
To begin with, we can create a basic example that takes one of the graphs from our preceding app and filters the data behind it based on the user’s input. In this case, we can ask the user to specify the type of tree owner (for example, a private owner or the Department of Public Works) and filter on those conditions using the st.multiselect()
function, which allows the user to select multiple...