← Learn/Streamlit

Learn Streamlit

40 lessons · Basics · Charts · Data · Deployment

0/39 completed
Lesson 1 of 10

st.write & st.markdown

st.write() is Streamlit's universal display function — it renders strings, DataFrames, Plotly figures, dicts and more based on the type passed. st.markdown() renders Markdown text with headers, bold, links and horizontal rules. Use st.title(), st.header(), st.subheader() for semantic headings that appear in the outline.

💡

Prefer st.markdown('---') for dividers and st.caption() for small grey footnote text. Avoid mixing st.write() and print() — print goes to terminal logs, not the browser.

Code ExamplePython · Streamlit
import streamlit as st
import pandas as pd

st.title("Sales Dashboard")
st.markdown("## Q1 2024 Overview")
st.write("Revenue grew **12%** vs prior year across all regions.")

# st.write auto-renders DataFrames
df = pd.DataFrame({
    "Region":  ["UK", "US", "EU"],
    "Revenue": [480_000, 720_000, 310_000],
})
st.write(df)

st.markdown("---")
st.caption("Data sourced from internal ERP — refreshed daily at 06:00 UTC")

Simulator

Streamlit Preview

📌 Sales Dashboard

── Q1 2024 Overview

Revenue grew 12% vs prior year across all regions.

┌ Region │ Revenue ┐

│ UK │ 480,000 │

│ US │ 720,000 │

│ EU │ 310,000 │

───────────────────

Data sourced from internal ERP — refreshed daily at 06:00 UTC

Quick Check

What does st.write() do when passed a pandas DataFrame?