|
| 1 | +--- |
| 2 | +title: Display progress and status |
| 3 | +slug: /library/api-reference/status |
| 4 | +--- |
| 5 | + |
| 6 | +# Display progress and status |
| 7 | + |
| 8 | +Streamlit provides a few methods that allow you to add animation to your |
| 9 | +apps. These animations include progress bars, status messages (like |
| 10 | +warnings), and celebratory balloons. |
| 11 | + |
| 12 | +<TileContainer> |
| 13 | +<RefCard href="/library/api-reference/status/st.progress"> |
| 14 | + |
| 15 | +<Image pure alt="screenshot" src="/images/api/progress.jpg" /> |
| 16 | + |
| 17 | +#### Progress bar |
| 18 | + |
| 19 | +Display a progress bar. |
| 20 | + |
| 21 | +```python |
| 22 | +for i in range(101): |
| 23 | + st.progress(i) |
| 24 | + do_something_slow() |
| 25 | +``` |
| 26 | + |
| 27 | +</RefCard> |
| 28 | +<RefCard href="/library/api-reference/status/st.spinner"> |
| 29 | + |
| 30 | +<Image pure alt="screenshot" src="/images/api/spinner.jpg" /> |
| 31 | + |
| 32 | +#### Spinner |
| 33 | + |
| 34 | +Temporarily displays a message while executing a block of code. |
| 35 | + |
| 36 | +```python |
| 37 | +with st.spinner("Please wait..."): |
| 38 | + do_something_slow() |
| 39 | +``` |
| 40 | + |
| 41 | +</RefCard> |
| 42 | +<RefCard href="/library/api-reference/status/st.status"> |
| 43 | + |
| 44 | +<Image pure alt="screenshot" src="/images/api/status.jpg" /> |
| 45 | + |
| 46 | +#### Status container |
| 47 | + |
| 48 | +Display output of long-running tasks in a container. |
| 49 | + |
| 50 | +```python |
| 51 | +with st.status('Running'): |
| 52 | + do_something_slow() |
| 53 | +``` |
| 54 | + |
| 55 | +</RefCard> |
| 56 | +<RefCard href="/library/api-reference/status/st.toast"> |
| 57 | + |
| 58 | +<Image pure alt="screenshot" src="/images/api/toast.jpg" /> |
| 59 | + |
| 60 | +#### Toast |
| 61 | + |
| 62 | +Briefly displays a toast message in the bottom-right corner. |
| 63 | + |
| 64 | +```python |
| 65 | +st.toast('Butter!', icon='🧈') |
| 66 | +``` |
| 67 | + |
| 68 | +</RefCard> |
| 69 | +<RefCard href="/library/api-reference/status/st.balloons"> |
| 70 | + |
| 71 | +<Image pure alt="screenshot" src="/images/api/balloons.jpg" /> |
| 72 | + |
| 73 | +#### Balloons |
| 74 | + |
| 75 | +Display celebratory balloons! |
| 76 | + |
| 77 | +```python |
| 78 | +st.balloons() |
| 79 | +``` |
| 80 | + |
| 81 | +</RefCard> |
| 82 | +<RefCard href="/library/api-reference/status/st.snow"> |
| 83 | + |
| 84 | +<Image pure alt="screenshot" src="/images/api/snow.jpg" /> |
| 85 | + |
| 86 | +#### Snowflakes |
| 87 | + |
| 88 | +Display celebratory snowflakes! |
| 89 | + |
| 90 | +```python |
| 91 | +st.snow() |
| 92 | +``` |
| 93 | + |
| 94 | +</RefCard> |
| 95 | +<RefCard href="/library/api-reference/status/st.error"> |
| 96 | + |
| 97 | +<Image pure alt="screenshot" src="/images/api/error.jpg" /> |
| 98 | + |
| 99 | +#### Error box |
| 100 | + |
| 101 | +Display error message. |
| 102 | + |
| 103 | +```python |
| 104 | +st.error("We encountered an error") |
| 105 | +``` |
| 106 | + |
| 107 | +</RefCard> |
| 108 | +<RefCard href="/library/api-reference/status/st.warning"> |
| 109 | + |
| 110 | +<Image pure alt="screenshot" src="/images/api/warning.jpg" /> |
| 111 | + |
| 112 | +#### Warning box |
| 113 | + |
| 114 | +Display warning message. |
| 115 | + |
| 116 | +```python |
| 117 | +st.warning("Unable to fetch image. Skipping...") |
| 118 | +``` |
| 119 | + |
| 120 | +</RefCard> |
| 121 | +<RefCard href="/library/api-reference/status/st.info"> |
| 122 | + |
| 123 | +<Image pure alt="screenshot" src="/images/api/info.jpg" /> |
| 124 | + |
| 125 | +#### Info box |
| 126 | + |
| 127 | +Display an informational message. |
| 128 | + |
| 129 | +```python |
| 130 | +st.info("Dataset is updated every day at midnight.") |
| 131 | +``` |
| 132 | + |
| 133 | +</RefCard> |
| 134 | +<RefCard href="/library/api-reference/status/st.success"> |
| 135 | + |
| 136 | +<Image pure alt="screenshot" src="/images/api/success.jpg" /> |
| 137 | + |
| 138 | +#### Success box |
| 139 | + |
| 140 | +Display a success message. |
| 141 | + |
| 142 | +```python |
| 143 | +st.success("Match found!") |
| 144 | +``` |
| 145 | + |
| 146 | +</RefCard> |
| 147 | +<RefCard href="/library/api-reference/status/st.exception"> |
| 148 | + |
| 149 | +<Image pure alt="screenshot" src="/images/api/exception.jpg" /> |
| 150 | + |
| 151 | +#### Exception output |
| 152 | + |
| 153 | +Display an exception. |
| 154 | + |
| 155 | +```python |
| 156 | +e = RuntimeError("This is an exception of type RuntimeError") |
| 157 | +st.exception(e) |
| 158 | +``` |
| 159 | + |
| 160 | +</RefCard> |
| 161 | +</TileContainer> |
| 162 | + |
| 163 | +<ComponentSlider> |
| 164 | + |
| 165 | +<ComponentCard href="https://github.com/Wirg/stqdm"> |
| 166 | + |
| 167 | +<Image pure alt="screenshot" src="/images/api/components/stqdm.jpg" /> |
| 168 | + |
| 169 | +#### Stqdm |
| 170 | + |
| 171 | +The simplest way to handle a progress bar in streamlit app. Created by [@Wirg](https://github.com/Wirg). |
| 172 | + |
| 173 | +```python |
| 174 | +from stqdm import stqdm |
| 175 | + |
| 176 | +for _ in stqdm(range(50)): |
| 177 | + sleep(0.5) |
| 178 | +``` |
| 179 | + |
| 180 | +</ComponentCard> |
| 181 | + |
| 182 | +<ComponentCard href="https://github.com/Socvest/streamlit-custom-notification-box"> |
| 183 | + |
| 184 | +<Image pure alt="screenshot" src="/images/api/components/custom-notification-box.jpg" /> |
| 185 | + |
| 186 | +#### Custom notification box |
| 187 | + |
| 188 | +A custom notification box with the ability to close it out. Created by [@Socvest](https://github.com/Socvest). |
| 189 | + |
| 190 | +```python |
| 191 | +from streamlit_custom_notification_box import custom_notification_box |
| 192 | + |
| 193 | +styles = {'material-icons':{'color': 'red'}, 'text-icon-link-close-container': {'box-shadow': '#3896de 0px 4px'}, 'notification-text': {'':''}, 'close-button':{'':''}, 'link':{'':''}} |
| 194 | +custom_notification_box(icon='info', textDisplay='We are almost done with your registration...', externalLink='more info', url='#', styles=styles, key="foo") |
| 195 | +``` |
| 196 | + |
| 197 | +</ComponentCard> |
| 198 | + |
| 199 | +<ComponentCard href="https://extras.streamlit.app/"> |
| 200 | + |
| 201 | +<Image pure alt="screenshot" src="/images/api/components/extras-emojis.jpg" /> |
| 202 | + |
| 203 | +#### Streamlit Extras |
| 204 | + |
| 205 | +A library with useful Streamlit extras. Created by [@arnaudmiribel](https://github.com/arnaudmiribel/). |
| 206 | + |
| 207 | +```python |
| 208 | +from streamlit_extras.let_it_rain import rain |
| 209 | + |
| 210 | +rain(emoji="🎈", font_size=54, |
| 211 | + falling_speed=5, animation_length="infinite",) |
| 212 | +``` |
| 213 | + |
| 214 | +</ComponentCard> |
| 215 | + |
| 216 | +</ComponentSlider> |
0 commit comments