Display a short message, known as a notification "toast".
The toast appears in the app's bottom-right corner and disappears after four seconds.
st.toast is not compatible with Streamlit's caching and cannot be called within a cached function.
st.toast(body, *, icon=None)
The string to display as Github-flavored Markdown. Syntax information can be found at: https://github.github.com/gfm.
This also supports:
icon (str or None)
An optional, keyword-only argument that specifies an emoji to use as the icon for the toast. Shortcodes are not allowed, please use a single character instead. E.g. "🚨", "🔥", "🤖", etc. Defaults to None, which means no icon is displayed.
import streamlit as st st.toast('Your edited image was saved!', icon='😍')
When multiple toasts are generated, they will stack. Hovering over a toast will stop it from disappearing. When hovering ends, the toast will disappear after four more seconds.
import streamlit as st import time if st.button('Three cheers'): st.toast('Hip!') time.sleep(.5) st.toast('Hip!') time.sleep(.5) st.toast('Hooray!', icon='🎉')
Toast messages can also be updated. Assign
st.toast(my_message) to a variable
and use the
.toast() method to update it. Note: if a toast has already disappeared
or been dismissed, the update will not be seen.
import streamlit as st import time def cook_breakfast(): msg = st.toast('Gathering ingredients...') time.sleep(1) msg.toast('Cooking...') time.sleep(1) msg.toast('Ready!', icon = "🥞") if st.button('Cook breakfast'): cook_breakfast()
Still have questions?
Our forums are full of helpful information and Streamlit experts.