eagle0504's picture
app updated
746d2f1

A newer version of the Streamlit SDK is available: 1.48.1

Upgrade
metadata
title: st.toast
slug: /develop/api-reference/status/st.toast
description: st.toast briefly displays a toast message in the bottom-right corner

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()