When using st.progress how do you remove the progress bar once the work is complete? The examples in the user guide and API docs don’t say.
Thank you for calling this out! It absolutely should be included in the docs. I’ll work to get it added.
In my meantime, you can call
.empty() on the progress bar to remove it like so:
import streamlit as st import time my_bar = st.progress(0) for percent_complete in range(100): time.sleep(0.1) my_bar.progress(percent_complete + 1) my_bar.empty()
Does this help with your use case?
Does that completely remove the element from the page?
Or will there still be a space where the bar was?
If I’m not mistaken, it should remove/clear the element from the page, without leaving a space where the bar was.
Well, it does clear the element, but just discovered that using it inside a cached function will invalidate the cache every time, so stops caching working.
That’s a shame because it’s useful to show progress on loading data.
EDIT: …or that may have just been me modifying a comment inside the function