How to clear and replace an image

Hi!

I have an image displayed, and I want that image to be replaced with another image when a button is pressed. I can get the second image to appear under the first, but I want to swap them out. Is there a way to do this, or can I clear the first image and then display the second?

1 Like

Hi @bevanny, welcome to the Streamlit community!

This design pattern can be achieved using st.empty:

Best,
Randy

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.