logo

Displaying Text

Streamlit has several functions for displaying text, each with a purpose.

import streamlit as st

st.title("Main Title")
st.header("Section Header")
st.subheader("Subsection")
st.text("Plain text")
st.write("Smart function - handles many types")

st.write() is the Swiss Army knife - it detects what you pass and formats appropriately. Pass a string, DataFrame, chart, or dictionary.

For formatted text, use markdown:

st.markdown("**Bold**, *italic*, and `code`")
st.markdown("- Bullet points\n- Like this")

Display code with syntax highlighting:

st.code("print('Hello')", language="python")

The text functions make it easy to explain your data and guide users through your app.

I cover text and layout in my Streamlit course.