Streamlit is a powerful open-source Python library that turns scripts into interactive web apps for data science and machine learning projects. It offers a wide range of functions to build interactive UI elements, display data, integrate media, and manage layouts. Below is a categorized list of important Streamlit functions:
Used to display text, data, code, and other elements.
Function | Purpose |
---|---|
st.title() |
Display a large title |
st.header() |
Display a header |
st.subheader() |
Display a subheader |
st.text() |
Display fixed text |
st.markdown() |
Render Markdown-formatted text |
st.code() |
Show code block |
st.latex() |
Render LaTeX expressions |
st.write() |
Generic write for any object (text, dataframe, plot, etc.) |
Create interactive widgets to receive user inputs.
Function | Input Type |
---|---|
st.button() |
Button |
st.checkbox() |
Boolean |
st.radio() |
Select one from multiple options |
st.selectbox() |
Dropdown menu |
st.multiselect() |
Multiple dropdown options |
st.slider() |
Range slider |
st.text_input() |
Text input |
st.text_area() |
Multi-line text input |
st.number_input() |
Numeric input |
st.date_input() |
Date picker |
st.time_input() |
Time picker |
st.file_uploader() |
File uploader |
st.color_picker() |
Color picker |
Display multimedia elements.
Function | Media Type |
---|---|
st.image() |
Display image |
st.audio() |
Play audio |
st.video() |
Play video |
Display structured data.
Function | Description |
---|---|
st.dataframe() |
Interactive table |
st.table() |
Static table |
st.json() |
Render JSON |
st.metric() |
Display a metric (e.g., KPI) |
Visualize data.
Function | Chart Type |
---|---|
st.line_chart() |
Line chart |
st.area_chart() |
Area chart |
st.bar_chart() |
Bar chart |
st.pyplot() |
Matplotlib |
st.altair_chart() |
Altair |
st.vega_lite_chart() |
Vega-Lite |
st.plotly_chart() |
Plotly |
st.bokeh_chart() |
Bokeh |
st.graphviz_chart() |
Graphviz diagrams |
st.map() |
Map visualization |
Manage layout and custom UI flow.
Function | Description |
---|---|
st.sidebar |
Add widgets to sidebar |
st.columns() |
Divide page into columns |
st.container() |
Custom containers |
st.expander() |
Collapsible section |
st.empty() |
Placeholder for dynamic updates |
st.tabs() |
Tabbed layout |
st.spinner() |
Show loading spinner |
st.toast() |
Show temporary message (new) |
Control app behavior.
Function | Description |
---|---|
st.cache_data() |
Cache data (e.g., API or computation) |
st.cache_resource() |
Cache models, connections |
st.session_state |
Manage state between reruns |
st.experimental_rerun() |
Force rerun |
st.stop() |
Stop execution |
st.form() / st.form_submit_button() |
Group widgets in a form |
Allow file download or read.
Function | Description |
---|---|
st.file_uploader() |
Upload file(s) |
st.download_button() |
Provide download link for file or text |
Customize appearance and behavior.
Function | Description |
---|---|
st.set_page_config() |
Set page title, layout, icon, etc. |
.streamlit/config.toml |
Persistent app config |