Hide or Collapse Widgets Upon Submit

Hello! Very new to streamlit but really enjoying learning more and working with this amazing product.

I’m attempting to make a simple interface that allows for a user to fine tune some elements for song recommendations.

Apologies if there is already an existing thread for this, was unable to locate anything concrete. I was wondering how one would be able to collapse, hide, or delete a widget upon button click. Ideally, after pressing “Get recommendations” I’d like the multiselect and other widgets to be hidden or deleted.

I currently have:

filter_options = st.multiselect("Select Desired Filters", ["Tempo", "Key", "Danceability", "Energy", "Instrumentalness", "Valence"], key='1')
final_filters = get_filters(filter_options)
if st.button("Get Recommendations 🎵"):
   r = get_recs(final_filters, search_track_dict)

where the widgets used for filtering are created and values from them are retrieved in the call to get_filters(). Not sure if there is a way to do this utilizing st.empty() or other, but any help would be appreciated. Thanks!

streamlit v 0.71, python 3.9

Hi @pkbro!

Welcome to the Streamlit Community!!! :partying_face: :partying_face: :partying_face: :partying_face: :partying_face: :tada:

I think the best option for this would be to use the st.beta_expander() function. You can have it initiate as open and then once the user has selected all of the options they can close the expander without rerunning your script (and losing the users selections).

Checkout out community post here
Checkout the Documentation here

Happy Streamlit-ing!