Streamlit is an open-source Python framework that transforms data scripts into interactive web applications with minimal code. Built specifically for data scientists and ML engineers, Streamlit eliminates the need for frontend development expertise β write simple Python scripts and instantly see results as responsive UIs. Its pure-Python declarative model runs scripts top-to-bottom on every interaction, automatically managing UI updates and enabling rapid prototyping. The framework's true power lies in its caching primitives, session state management, and fragment-based partial reruns, which together enable building production-grade data apps that handle complex workflows, real-time updates, and stateful interactions efficiently.
What This Cheat Sheet Covers
This topic spans 24 focused tables and 141 indexed concepts, 81 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Core Display Functions
These are the building blocks for putting text, formatting, and structure on the screen. The standout is st.write β Streamlit's catch-all that figures out the right rendering for almost anything you hand it β while the rest give you explicit control over titles, markdown, code blocks, and even LaTeX math when you want it.
| Function | Example | Description | |
|---|---|---|---|
st.write("Hello **world**!")st.write(df)st.write(fig) | Streamlit's "magic" function that intelligently renders almost any Python object β dataframes, charts, markdown, dicts, or plain text β choosing the appropriate display format automatically. | ||
st.markdown("# Header")st.markdown("Text with **bold**") | β’ Renders a string as formatted Markdown with full support for headers, emphasis, lists, links, and inline HTML β’ set unsafe_allow_html=True to enable raw HTML rendering | ||
st.title("My App Title") | Displays text in large title formatting at the top of your app β the visual headline users see first. | ||
st.header("Section Header") | Displays text in header formatting β larger than regular text but smaller than title β used to organize app sections. | ||
st.subheader("Subsection") | Displays text in subheader formatting β useful for creating visual hierarchy within sections. | ||
st.caption("Small explanatory text") | Displays text in small font β ideal for footnotes, disclaimers, or supplementary information. | ||
st.text("Fixed-width text") | Displays preformatted, fixed-width text with no markdown processing β preserves whitespace and line breaks exactly as written. | ||
st.code("x = 42", language="python") | Displays a syntax-highlighted code block with optional language specification for proper highlighting. | ||
st.latex(r"\int_a^b x^2 \,dx") | Renders mathematical expressions using LaTeX notation β essential for displaying formulas and equations. | ||
st.divider() | Inserts a horizontal line separator to visually divide content sections. | ||
with st.echo(): st.write("Shows code") | Displays the code itself before executing it β perfect for tutorials and documentation where you want to show and run code simultaneously. | ||
st.html("<p>Custom HTML</p>") | Renders raw HTML strings directly in your app β enables custom styling and advanced layouts beyond Streamlit's built-in components. |