Hello there 👋

Thanks for stopping by! We use cookies to help us understand how you interact with our website.

By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.

Display a loading spinner while executing a block of code.

Function signature[source]

st.spinner(text="In progress...", *, show_time=False)

Parameters

text (str)

The text to display next to the spinner. This defaults to "In progress...".

The text can optionally contain GitHub-flavored Markdown. Syntax information can be found at: https://github.github.com/gfm.

See the body parameter of st.markdown for additional, supported Markdown directives.

show_time (bool)

Whether to show the elapsed time next to the spinner text. If this is False (default), no time is displayed. If this is True, elapsed time is displayed with a precision of 0.1 seconds. The time format is not configurable.

Example

import streamlit as st
import time

with st.spinner("Wait for it...", show_time=True):
    time.sleep(5)
st.success("Done!")
st.button("Rerun")
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.