How to remove progress bar

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.

Hi @quantoid,

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?

Happy Streamlit-ing! :balloon:
Snehan

4 Likes

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

I just want to point out this does not appear to ever have made it to the docs for st.progress() - I think it’s non-obvious enough that it should be included.

1.5 years after the last person and the docs seem to still be missing this :slight_smile: so bumping again

1 Like

Happy new year! Please add this to the documentation haha.

EDIT: OMG, it is in the documentation now! (I didn’t see it before commenting).