A faster way to build and share data apps
A faster way to build and share data apps. Streamlit transforms Python scripts into interactive web applications with minimal code, providing a declarative API for creating data dashboards, reports, and chat applications with automatic UI generation, real-time updates, and built-in widgets for user interaction.
pip install streamlitimport streamlit as stimport streamlit as st
import pandas as pd
import numpy as np
# Display text and markdown
st.title("My Data App")
st.write("Hello, world!")
st.markdown("**Bold text** and *italic text*")
# Display data
data = pd.DataFrame({
'name': ['Alice', 'Bob', 'Charlie'],
'age': [25, 30, 35],
'score': [85.5, 92.0, 78.3]
})
st.dataframe(data)
# Add interactive widgets
name = st.text_input("Enter your name:")
age = st.slider("Select your age:", 0, 100, 25)
if st.button("Submit"):
st.success(f"Hello {name}, you are {age} years old!")
# Create simple charts
chart_data = pd.DataFrame(
np.random.randn(20, 3),
columns=['a', 'b', 'c']
)
st.line_chart(chart_data)Streamlit's architecture centers around the DeltaGenerator pattern:
@st.cache_data and @st.cache_resource decoratorsThis design enables rapid prototyping while providing the foundation for production-ready data applications, integrating seamlessly with the Python data science ecosystem including pandas, NumPy, matplotlib, Plotly, and hundreds of specialized libraries.
Core display functions for text, data, and content rendering including markdown, code, JSON, and media elements.
def write(*args, unsafe_allow_html=False, **kwargs): ...
def markdown(body, unsafe_allow_html=False, help=None): ...
def text(body): ...
def code(body, language=None, line_numbers=False): ...
def json(body): ...
def latex(body): ...
def html(body, width=None, height=None, scrolling=False): ...
def write_stream(stream): ...Interactive widgets for user input including buttons, text inputs, sliders, selectors, and file uploads.
def button(label, key=None, help=None, on_click=None, **kwargs): ...
def text_input(label, value="", max_chars=None, key=None, **kwargs): ...
def slider(label, min_value=None, max_value=None, value=None, **kwargs): ...
def selectbox(label, options, index=0, key=None, **kwargs): ...
def multiselect(label, options, default=None, key=None, **kwargs): ...
def checkbox(label, value=False, key=None, **kwargs): ...
def file_uploader(label, type=None, accept_multiple_files=False, **kwargs): ...
def chat_input(placeholder="Your message", key=None, max_chars=None, **kwargs): ...
def chat_message(name, avatar=None, width="stretch"): ...Advanced data display components including interactive dataframes, static tables, and metrics display.
def dataframe(data=None, width=None, height=None, use_container_width=False, **kwargs): ...
def data_editor(data, width=None, height=None, disabled=False, **kwargs): ...
def table(data=None): ...
def metric(label, value, delta=None, delta_color="normal", **kwargs): ...Built-in charting functions and third-party chart library integrations for data visualization.
def line_chart(data=None, x=None, y=None, color=None, **kwargs): ...
def bar_chart(data=None, x=None, y=None, color=None, **kwargs): ...
def area_chart(data=None, x=None, y=None, color=None, **kwargs): ...
def scatter_chart(data=None, x=None, y=None, color=None, size=None, **kwargs): ...
def plotly_chart(figure_or_data, use_container_width=False, **kwargs): ...
def altair_chart(altair_chart, use_container_width=False, **kwargs): ...
def pyplot(fig=None, clear_figure=None, **kwargs): ...Layout management and container elements for organizing app structure including columns, tabs, sidebars, and forms.
def columns(spec, gap="small"): ...
def tabs(tab_labels): ...
def container(height=None, border=False): ...
def expander(label, expanded=False): ...
sidebar: DeltaGenerator
def form(key, clear_on_submit=False, border=True): ...
def empty(): ...Media display and status messaging including images, audio, video, and user feedback elements.
def image(image, caption=None, width=None, **kwargs): ...
def audio(data, format="audio/wav", **kwargs): ...
def video(data, format="video/mp4", **kwargs): ...
def pdf(data, width=None, height=600): ...
def success(body, icon=True): ...
def error(body, icon=True): ...
def warning(body, icon=True): ...
def info(body, icon=True): ...
def exception(exception): ...
def toast(body, icon=None): ...
def balloons(): ...
def snow(): ...
def badge(label, icon=None, color=None): ...
def feedback(options, key=None, disabled=False, **kwargs): ...State management, caching mechanisms, and performance optimization tools.
session_state: SessionStateProxy
def cache_data(func=None, *, ttl=None, max_entries=None, **kwargs): ...
def cache_resource(func=None, *, ttl=None, max_entries=None, **kwargs): ...Advanced functionality including authentication, navigation, fragments, dialogs, and custom components.
def navigation(pages, position="sidebar"): ...
class Page: ...
def fragment(func=None, *, run_every=None, **kwargs): ...
def dialog(title, *, width="large"): ...
def connection(name, type=None, **kwargs): ...
def login(user_info_provider=None, **kwargs): ...App configuration, execution control, and utility functions.
def set_page_config(page_title=None, page_icon=None, layout="centered", **kwargs): ...
def rerun(): ...
def stop(): ...
def switch_page(page): ...
def get_option(key): ...
def set_option(key, value): ...
def echo(code_location="above"): ...
def help(obj): ...
def logo(image, link=None, icon_image=None, size="medium"): ...
context: ContextProxy
secrets: SecretsProxyInstall with Tessl CLI
npx tessl i tessl/pypi-streamlit@1.49.0