The fastest way to build and share data apps
Streamlit is a comprehensive Python web application framework that enables developers to rapidly transform data scripts into interactive, shareable web applications. It provides a simple, declarative API for creating rich user interfaces with widgets like sliders, charts, maps, and data tables, all without requiring frontend development knowledge.
pip install streamlitimport streamlit as stFor custom components:
import streamlit.components.v1 as componentsType imports for API signatures:
from typing import Union, List, Dict, Literal, Any, Optional, ContextManager, NoReturnimport streamlit as st
import pandas as pd
import numpy as np
# Set page configuration
st.set_page_config(
page_title="My App",
page_icon="🚀",
layout="wide"
)
# Create content
st.title("My Streamlit App")
st.write("Welcome to my data application!")
# Display data
data = pd.DataFrame({
'x': np.random.randn(100),
'y': np.random.randn(100)
})
st.dataframe(data)
st.line_chart(data)
# 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!")Streamlit follows an immediate-mode GUI paradigm where:
The framework handles the complete web stack including automatic UI generation, real-time updates, WebSocket communication, and deployment capabilities.
Core functions for displaying text, data, and status messages including titles, headers, markdown, tables, dataframes, JSON, metrics, and various alert types.
def title(body: str, anchor: str = None) -> DeltaGenerator: ...
def header(body: str, anchor: str = None) -> DeltaGenerator: ...
def subheader(body: str, anchor: str = None) -> DeltaGenerator: ...
def text(body: str) -> DeltaGenerator: ...
def markdown(body: str, unsafe_allow_html: bool = False) -> DeltaGenerator: ...
def latex(body: str) -> DeltaGenerator: ...
def code(body: str, language: str = "python") -> DeltaGenerator: ...
def caption(body: str, unsafe_allow_html: bool = False) -> DeltaGenerator: ...
def dataframe(data, width: int = None, height: int = None, use_container_width: bool = False) -> DeltaGenerator: ...
def table(data) -> DeltaGenerator: ...
def json(body) -> DeltaGenerator: ...
def metric(label: str, value, delta=None, delta_color: str = "normal") -> DeltaGenerator: ...
def success(body: str) -> DeltaGenerator: ...
def info(body: str) -> DeltaGenerator: ...
def warning(body: str) -> DeltaGenerator: ...
def error(body: str) -> DeltaGenerator: ...
def exception(exception: Exception) -> DeltaGenerator: ...Interactive form controls for user input including buttons, text fields, sliders, selectors, file uploaders, and specialized inputs like date pickers and color choosers.
def button(label: str, key: str = None, help: str = None, on_click=None, args=None, kwargs=None, type: Literal["primary", "secondary"] = "secondary", disabled: bool = False) -> bool: ...
def download_button(label: str, data, file_name: str = None, mime: str = None) -> bool: ...
def checkbox(label: str, value: bool = False, key: str = None) -> bool: ...
def radio(label: str, options, index: int = 0, key: str = None) -> Any: ...
def selectbox(label: str, options, index: int = 0, key: str = None) -> Any: ...
def multiselect(label: str, options, default=None, key: str = None) -> List[Any]: ...
def slider(label: str, min_value=None, max_value=None, value=None, step=None, key: str = None) -> Any: ...
def text_input(label: str, value: str = "", key: str = None, type: str = "default") -> str: ...
def number_input(label: str, min_value=None, max_value=None, value=None, step=None, key: str = None) -> Union[int, float]: ...
def text_area(label: str, value: str = "", height: int = None, key: str = None) -> str: ...
def date_input(label: str, value=None, min_value=None, max_value=None, key: str = None): ...
def time_input(label: str, value=None, key: str = None): ...
def file_uploader(label: str, type=None, accept_multiple_files: bool = False, key: str = None): ...
def camera_input(label: str, key: str = None): ...
def color_picker(label: str, value: str = "#000000", key: str = None) -> str: ...Functions for organizing content including columns, tabs, expandable sections, forms, and container management for creating sophisticated multi-panel layouts.
def container() -> DeltaGenerator: ...
def columns(spec) -> List[DeltaGenerator]: ...
def tabs(tab_names: List[str]) -> List[DeltaGenerator]: ...
def expander(label: str, expanded: bool = False) -> DeltaGenerator: ...
def empty() -> DeltaGenerator: ...
def form(key: str) -> DeltaGenerator: ...
def form_submit_button(label: str = "Submit", help: str = None) -> bool: ...Comprehensive visualization and media display capabilities including native chart types, integration with popular plotting libraries, and multimedia content rendering.
def line_chart(data=None, x: str = None, y: str = None, width: int = None, height: int = None) -> DeltaGenerator: ...
def area_chart(data=None, x: str = None, y: str = None, width: int = None, height: int = None) -> DeltaGenerator: ...
def bar_chart(data=None, x: str = None, y: str = None, width: int = None, height: int = None) -> DeltaGenerator: ...
def pyplot(fig=None, clear_figure: bool = None) -> DeltaGenerator: ...
def altair_chart(altair_chart, use_container_width: bool = False) -> DeltaGenerator: ...
def vega_lite_chart(spec: dict, use_container_width: bool = False) -> DeltaGenerator: ...
def plotly_chart(figure_or_data, use_container_width: bool = False) -> DeltaGenerator: ...
def bokeh_chart(figure, use_container_width: bool = False) -> DeltaGenerator: ...
def pydeck_chart(pydeck_obj=None, use_container_width: bool = False) -> DeltaGenerator: ...
def graphviz_chart(figure_or_dot: Union[str, graphviz.Graph], use_container_width: bool = False) -> DeltaGenerator: ...
def map(data=None, zoom: int = None, use_container_width: bool = False) -> DeltaGenerator: ...
def image(image, caption: str = None, width: int = None, use_column_width: str = None) -> DeltaGenerator: ...
def audio(data, format: str = "audio/wav", start_time: int = 0) -> DeltaGenerator: ...
def video(data, format: str = "video/mp4", start_time: int = 0) -> DeltaGenerator: ...Application configuration, performance optimization through caching decorators, session state management, and utility functions for app lifecycle control.
def set_page_config(page_title: str = None, page_icon: str = None, layout: str = "centered", initial_sidebar_state: str = "auto") -> None: ...
def get_option(key: str): ...
def set_option(key: str, value) -> None: ...
@cache
def cached_function(): ...
@experimental_memo
def memo_function(): ...
@experimental_singleton
def singleton_function(): ...
def stop() -> NoReturn: ...
def balloons() -> DeltaGenerator: ...
def snow() -> DeltaGenerator: ...
def progress(value: Union[int, float]) -> DeltaGenerator: ...
def spinner(text: str = "In progress...") -> ContextManager[DeltaGenerator]: ...
def echo(code_location: str = "above") -> ContextManager[DeltaGenerator]: ...
def write(*args, **kwargs) -> DeltaGenerator: ...
def help(obj) -> DeltaGenerator: ...
def experimental_rerun() -> NoReturn: ...
def rerun() -> NoReturn: ...
def experimental_get_query_params() -> Dict[str, List[str]]: ...
def experimental_set_query_params(**query_params) -> None: ...
def experimental_show(*args, **kwargs) -> None: ...
def beta_container() -> DeltaGenerator: ...
def beta_expander(label: str, expanded: bool = False) -> DeltaGenerator: ...
def beta_columns(spec) -> List[DeltaGenerator]: ...Framework for creating and using custom HTML/JavaScript components, enabling extension of Streamlit's built-in widget set with reusable interactive elements.
def declare_component(name: str, path: str = None, url: str = None) -> ComponentCallable: ...
def html(body: str, width: int = None, height: int = None, scrolling: bool = False) -> None: ...
def iframe(src: str, width: int = None, height: int = None, scrolling: bool = False) -> None: ...class DeltaGeneratorProto:
"""Protocol for delta generator objects."""
class SessionStateProxy:
"""Proxy for session state access."""
def __getitem__(self, key: str) -> Any: ...
def __setitem__(self, key: str, value: Any) -> None: ...
def __contains__(self, key: str) -> bool: ...
def __delitem__(self, key: str) -> None: ...
class SecretsProxy:
"""Proxy for secrets access."""
def __getitem__(self, key: str) -> Any: ...
def __contains__(self, key: str) -> bool: ...
class UserInfoProxy:
"""Proxy for user information access (experimental)."""
@property
def email(self) -> str: ...
# Special variables
session_state: SessionStateProxy
secrets: SecretsProxy
experimental_user: UserInfoProxy
sidebar: DeltaGeneratorStreamlit defines several specialized exceptions for different error conditions:
class StreamlitAPIException(Exception):
"""Base exception for Streamlit API errors."""
class NoSessionContext(StreamlitAPIException):
"""Raised when no session context is available."""
class DuplicateWidgetID(StreamlitAPIException):
"""Raised when duplicate widget keys are used."""Common error patterns:
DuplicateWidgetID exceptionsNoSessionContextStreamlitAPIExceptionInstall with Tessl CLI
npx tessl i tessl/pypi-streamlit@1.16.0