Table of Contents
hide
import streamlit as st
import os
if st.button("Close"):
os._exit(0) # Force exit the Streamlit server.
----------- OR ------------
import streamlit as st
import os
if st.form_submit_button("Exit"):
st.write("App is closing...")
os._exit(0)
NB :
This will close the streamlit server/process forcibly and then we can manually close the browser page and restart the streamlit app again for proper functioning.
Example : A Streamlit source codes to create a Colored Title/Heading text.
import streamlit as st
st.write("<div style='text-align: center;color:green;'><h1>User Registration Module</h1></div>", unsafe_allow_html=True)
----------- OR -----------
import streamlit as st
st.markdown("<h1 style='text-align: center; color:red;'>User Registration</h1>", unsafe_allow_html=True)
NB:
•st.markdown() allows you to use HTML inside Streamlit.
•The CSS style (text-align: center;) centers the title.
•unsafe_allow_html=True enables rendering of raw HTML.
Example : A Streamlit source codes to create a Colored Label text.
import streamlit as st
st.markdown("<p style='color:red; font-size:18px; font-weight:bold; margin-bottom:-30px;'>Slno</p>", unsafe_allow_html=True)
slno = st.text_input("")
#slno = st.text_input("Slno") # Regular text input
Example : A Streamlit source codes to create different types of Messages text.
import streamlit as st
st.success("✅ Data inserted successfully!")
st.error("❌ An error occurred. Please try again.")
st.warning("⚠️ This action cannot be undone!")
st.info("ℹ️ This is an informational message.")
0 Comments