A problem with st.expander is that each time the code reruns it returns to the expanded/closed state determined by the expanded=True/False argument. Apparently this is because the expanded state is handled by the front end and not passed to the back end. Can this be bridged with a component? Can a js component be written that senses the st.expander state and pass it back to Python via Streamlit.setComponentValue()?
Hi @efrank
Streamlit has a session state that you can use to remember the True/False state of the expander widget.
More info on Session State in the Docs page:
And some example code snippets that you can get ideas from: