Remove a Markdown

Hi all. First of all, great tool! Congratulations for it. This is something I was really looking for in the last 2 years.

My question:
By now I have to update a Markdown as things change in the app. Is it possible to remove or update a Markdown, so it doesn’t duplicate?

Thank you


I decided to create myself a function with the possibility of not only removing a Markdown, but also customizing it as a success, warning or error (danger) message:

1- create a file named “” inside your project’s folder;
2- inside the file, put the following code:

import time
import streamlit as st

# How to use:
# ============
# msg = string
# wait = integer - default to 3
# type_ = string - default to warning (success, warning, danger)

def customMsg(msg, wait=3, type_='warning'):
    placeholder = st.empty()
    styledMsg = f'\
        <div class="element-container" style="width: 693px;">\
            <div class="alert alert-{type_} stAlert" style="width: 693px;">\
                <div class="markdown-text-container">\
    placeholder.markdown(styledMsg, unsafe_allow_html=True)

3- inside your Streamlit web app, import the module:
from customMsg import customMsg

4- use it as in the example below:

your message (string), time to sleep before disappear (integer), type of message - ‘warning’, ‘success’ or ‘danger’ (string)

msg = 'This is my message to the user.'
customMsg(msg, 3, 'warning')

Hi @julio, glad to hear you figured out a solution.

In general, you can write over a Markdown section by reusing the same st.empty() placeholder, so you might not need your own markdown function, but it’s also possible I’m not understanding your use case.

1 Like