-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add controls to Show/Hide individual sections or widgets #958
Description
Problem
Pertaining to the idea of giving users control over which sections of a Streamlit app are being shown:
At the moment (streamlit 0.53) you can use widgets to show and hide sections, e.g. using st.checkbox to activate a particular chunk of code.
It would be nicer to have controls directly on the widgets themselves to "show" and "hide" at the user's behest.
Solution
MVP: (First thought): a new Streamlit object (say st.section) that you could use to create a show/hide div containing all the elements that were created under that line of code. E.g.
st.subheader("A Chart you can show or hide")
with st.section(label="the_chart"):
st.write(some_dataframe)
Possible additions: It would be nice to have the ability to show/hide ANY arbitrary object via the user interface. This might mean expanding the API to include a keyword on most or all objects that either activates or suppresses this ability in the UI.
One idea would be a "switch" or "toggle" UI piece whose actions are attached to the proposed st.section object.
Additional context
From Streamlit discussion forum topic: https://discuss.streamlit.io/t/hide-collapse-fold-a-section/1579