Streamlit Title

Streamlit st.title displays text in title formatting.
The st.title() function in Streamlit displays a large, bold title at the top of your app.
It is typically used for headings, titles, or to highlight important sections of your application.
 
 
Need a Streamlit Developer? Click here

Syntax

				
					import streamlit as st

st.title(body, anchor=None, *, help=None, width="stretch")

				
			

Example

				
					import streamlit as st


st.title("Welcome to My Streamlit App")
st.title("_Streamlit_ is :blue[cool] :sunglasses:")



				
			

Adding Emojis

You can include emojis in your title text by using Unicode characters or emoji shortcodes.
				
					import streamlit as st

st.title("Hello, Streamlit! 🚀")

st.title("Data Analysis 📊 with Streamlit")

st.title("🏆 Welcome to My Dashboard")


				
			

Using variable in Title

				
					import streamlit as st

app_name = "My Streamlit App"

st.title(f"Welcome to {app_name}")

				
			

Dynamic Title with User Input

we can create a dynamic title that changes based on user input.
				
					import streamlit as st

username = st.text_input("Enter your name:")

if username:
    st.title(f"Welcome, {username}!")
else:
    st.title("Welcome to My Streamlit App")


				
			

Custom Title Styling

While st.title() has a default style, you can customize the appearance of your title using Markdown or HTML.
				
					import streamlit as st

st.markdown("<h1 style='color: blue;'>Custom Styled Title</h1>", unsafe_allow_html=True)


				
			
				
					st.markdown("<h1 style='font-family: Courier New; color: green;'>Another Custom Title</h1>", unsafe_allow_html=True)

				
			
				
					st.markdown("<h1 style='text-align: center; color: red;'>Centered Title</h1>", unsafe_allow_html=True)


				
			
				
					st.markdown("""
    <style>
        .gradient-title {
            background: linear-gradient(90deg, #ff6a00, #ee0979);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-size: 42px;
            text-align: center;
            font-weight: bold;
        }
    </style>
""", unsafe_allow_html=True)


st.markdown("<h1 class='gradient-title'>🔥 Streamlit Dashboard</h1>", unsafe_allow_html=True)

				
			

Interactive Titles With State

You can create interactive titles that change based on user actions or application state.
				
					import streamlit as st

if "count" not in st.session_state:
    st.session_state.count = 0

if st.button("Click Me"):
    st.session_state.count += 1

st.title(f"🔥 Button clicked {st.session_state.count} times!")

				
			

The st.title() function might look simple, but when combined with variables, session state, HTML, and CSS, it becomes a powerful tool for creating beautiful dashboards and interactive UIs.

 

 

Learn More About Streamlit: Click Here

 

Watch Videos on Streamlit:

Leave a Reply

Your email address will not be published. Required fields are marked *