- Spec files
pypi-streamlit
Describes: pkg:pypi/streamlit@1.49.x
- Description
- A faster way to build and share data apps
- Author
- tessl
- Last updated
index.md docs/
1# Streamlit23A 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.45## Package Information67- **Package Name**: streamlit8- **Language**: Python9- **Installation**: `pip install streamlit`1011## Core Imports1213```python14import streamlit as st15```1617## Basic Usage1819```python20import streamlit as st21import pandas as pd22import numpy as np2324# Display text and markdown25st.title("My Data App")26st.write("Hello, world!")27st.markdown("**Bold text** and *italic text*")2829# Display data30data = pd.DataFrame({31'name': ['Alice', 'Bob', 'Charlie'],32'age': [25, 30, 35],33'score': [85.5, 92.0, 78.3]34})35st.dataframe(data)3637# Add interactive widgets38name = st.text_input("Enter your name:")39age = st.slider("Select your age:", 0, 100, 25)40if st.button("Submit"):41st.success(f"Hello {name}, you are {age} years old!")4243# Create simple charts44chart_data = pd.DataFrame(45np.random.randn(20, 3),46columns=['a', 'b', 'c']47)48st.line_chart(chart_data)49```5051## Architecture5253Streamlit's architecture centers around the DeltaGenerator pattern:5455- **DeltaGenerator**: Core class that generates UI elements and manages the app's visual tree56- **Session State**: Persistent state management across user interactions and app reruns57- **Caching System**: Performance optimization through `@st.cache_data` and `@st.cache_resource` decorators58- **Widget System**: Automatic state synchronization between UI elements and Python variables59- **Rerun Model**: Automatic script re-execution on user interaction, with delta updates to the frontend6061This 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.6263## Capabilities6465### Display and Content6667Core display functions for text, data, and content rendering including markdown, code, JSON, and media elements.6869```python { .api }70def write(*args, unsafe_allow_html=False, **kwargs): ...71def markdown(body, unsafe_allow_html=False, help=None): ...72def text(body): ...73def code(body, language=None, line_numbers=False): ...74def json(body): ...75def latex(body): ...76def html(body, width=None, height=None, scrolling=False): ...77def write_stream(stream): ...78```7980[Display and Content](./display-content.md)8182### Input Widgets8384Interactive widgets for user input including buttons, text inputs, sliders, selectors, and file uploads.8586```python { .api }87def button(label, key=None, help=None, on_click=None, **kwargs): ...88def text_input(label, value="", max_chars=None, key=None, **kwargs): ...89def slider(label, min_value=None, max_value=None, value=None, **kwargs): ...90def selectbox(label, options, index=0, key=None, **kwargs): ...91def multiselect(label, options, default=None, key=None, **kwargs): ...92def checkbox(label, value=False, key=None, **kwargs): ...93def file_uploader(label, type=None, accept_multiple_files=False, **kwargs): ...94def chat_input(placeholder="Your message", key=None, max_chars=None, **kwargs): ...95def chat_message(name, avatar=None, width="stretch"): ...96```9798[Input Widgets](./input-widgets.md)99100### Data Display101102Advanced data display components including interactive dataframes, static tables, and metrics display.103104```python { .api }105def dataframe(data=None, width=None, height=None, use_container_width=False, **kwargs): ...106def data_editor(data, width=None, height=None, disabled=False, **kwargs): ...107def table(data=None): ...108def metric(label, value, delta=None, delta_color="normal", **kwargs): ...109```110111[Data Display](./data-display.md)112113### Charts and Visualizations114115Built-in charting functions and third-party chart library integrations for data visualization.116117```python { .api }118def line_chart(data=None, x=None, y=None, color=None, **kwargs): ...119def bar_chart(data=None, x=None, y=None, color=None, **kwargs): ...120def area_chart(data=None, x=None, y=None, color=None, **kwargs): ...121def scatter_chart(data=None, x=None, y=None, color=None, size=None, **kwargs): ...122def plotly_chart(figure_or_data, use_container_width=False, **kwargs): ...123def altair_chart(altair_chart, use_container_width=False, **kwargs): ...124def pyplot(fig=None, clear_figure=None, **kwargs): ...125```126127[Charts and Visualizations](./charts-visualizations.md)128129### Layout and Containers130131Layout management and container elements for organizing app structure including columns, tabs, sidebars, and forms.132133```python { .api }134def columns(spec, gap="small"): ...135def tabs(tab_labels): ...136def container(height=None, border=False): ...137def expander(label, expanded=False): ...138sidebar: DeltaGenerator139def form(key, clear_on_submit=False, border=True): ...140def empty(): ...141```142143[Layout and Containers](./layout-containers.md)144145### Media and Status146147Media display and status messaging including images, audio, video, and user feedback elements.148149```python { .api }150def image(image, caption=None, width=None, **kwargs): ...151def audio(data, format="audio/wav", **kwargs): ...152def video(data, format="video/mp4", **kwargs): ...153def pdf(data, width=None, height=600): ...154def success(body, icon=True): ...155def error(body, icon=True): ...156def warning(body, icon=True): ...157def info(body, icon=True): ...158def exception(exception): ...159def toast(body, icon=None): ...160def balloons(): ...161def snow(): ...162def badge(label, icon=None, color=None): ...163def feedback(options, key=None, disabled=False, **kwargs): ...164```165166[Media and Status](./media-status.md)167168### State and Caching169170State management, caching mechanisms, and performance optimization tools.171172```python { .api }173session_state: SessionStateProxy174def cache_data(func=None, *, ttl=None, max_entries=None, **kwargs): ...175def cache_resource(func=None, *, ttl=None, max_entries=None, **kwargs): ...176```177178[State and Caching](./state-caching.md)179180### Advanced Features181182Advanced functionality including authentication, navigation, fragments, dialogs, and custom components.183184```python { .api }185def navigation(pages, position="sidebar"): ...186class Page: ...187def fragment(func=None, *, run_every=None, **kwargs): ...188def dialog(title, *, width="large"): ...189def connection(name, type=None, **kwargs): ...190def login(user_info_provider=None, **kwargs): ...191```192193[Advanced Features](./advanced-features.md)194195### Configuration and Control196197App configuration, execution control, and utility functions.198199```python { .api }200def set_page_config(page_title=None, page_icon=None, layout="centered", **kwargs): ...201def rerun(): ...202def stop(): ...203def switch_page(page): ...204def get_option(key): ...205def set_option(key, value): ...206def echo(code_location="above"): ...207def help(obj): ...208def logo(image, link=None, icon_image=None, size="medium"): ...209context: ContextProxy210secrets: SecretsProxy211```212213[Configuration and Control](./configuration-control.md)