Open LeoTafti opened 3 years ago
Hi!
I'm interested in this issue, any updates so far?
As well as knowing the expanded state, it would be usefull to alter the expanded state too (I want to colapse an expander when something happens).
+1
Me too.
I'm quite interested also in this issue. I would like to avoid API requests which are sent under unexpanded st.expander.
Getting expander state is a must especially when I need to monitor if users visit the content inside, looking forward to seeing an update!
Would like to see this. I want to hide charts etc not in use which are quite processor intensive and only run the code when the expander is expanded. Something like:
exp = st.expander("Something Heavy")
with exp:
if exp.expanded:
st.write(heavy_function())
At the moment, everything is run, even in the hidden content.
Could also be included as an attribute for the expander:
with st.expander("Something Heavy", run_when_hidden=False):
st.write(heavy_function())
(Psuedo-code, but you get the idea 😉)
+1
This would be an excellent addition! I load multiple expanders that contain some "heavy" code. The initial UI delay when loading is somewhat annoying but using @st.cache helps.
Had anyone try this method:
if 'is_expanded' not in st.session_state:
st.session_state['is_expanded'] = True
container = st.expander("XXX", expanded=st.session_state['is_expanded'])
with container:
[DO STUFF]
st.session_state['is_expanded'] = False
I thought it would be a good idea, but working to me though.
Had anyone try this method:
if 'is_expanded' not in st.session_state: st.session_state['is_expanded'] = True container = st.expander("XXX", expanded=st.session_state['is_expanded']) with container: [DO STUFF] st.session_state['is_expanded'] = False
I thought it would be a good idea, but working to me though.
Working only after manual rerun.
This would be a useful functionality. In my use-case, I have two expanders and each has a radio list in it. I want to be able to say - if one expander is expanded (expander_state = True) then radio_selection would use the selection in this expander.
Hi,
This is a useful feature. Is there any update on it?
+1
Hope to add this feature. Every time you change something in the expander, it will shrink automatically!!!
on_expand
callback.+1
+1
Hi! Any update on this? Saw it had been moved back on the roadmap :(
Please implement expander state as described...this is important and impacts relevance of streamlit to broader use.
+1 !!!
+1 The same will be useful for tabs as well!
+1
Hey there, any plans to introduce this?
Thanks!
Problem
I'd like to be able to know whether a
st.expander
is expanded or collapsed (e.g. to show something on the main layout only when an expander in the sidebar is in expanded state).Solution
MVP: Something like
st.expander().expanded
as abool
would be nice.Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.