• Stars
    star
    455
  • Rank 96,175 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Templates and example code for creating Streamlit Components

Streamlit Component Templates

This repo contains templates and example code for creating Streamlit Components.

For complete information, please see the Streamlit Components documentation!

Overview

A Streamlit Component is made out of a Python API and a frontend (built using any web tech you prefer).

A Component can be used in any Streamlit app, can pass data between Python and frontend code, and and can optionally be distributed on PyPI for the rest of the world to use.

  • Create a component's API in a single line of Python:
import streamlit.components.v1 as components

# Declare the component:
my_component = components.declare_component("my_component", path="frontend/build")

# Use it:
my_component(greeting="Hello", name="World")
  • Build the component's frontend out of HTML and JavaScript (or TypeScript, or ClojureScript, or whatever you fancy). React is supported, but not required:
class MyComponent extends StreamlitComponentBase {
    public render(): ReactNode {
        // Access arguments from Python via `this.props.args`:
        const greeting = this.props.args["greeting"]
        const name = this.props.args["name"]
        return <div>{greeting}, {name}!</div>
    }
}

Quickstart

  • Ensure you have Python 3.6+, Node.js, and npm installed.
  • Clone this repo.
  • Create a new Python virtual environment for the template:
$ cd template
$ python3 -m venv venv  # create venv
$ . venv/bin/activate   # activate venv
$ pip install streamlit # install streamlit
  • Initialize and run the component template frontend:
$ cd template/my_component/frontend
$ npm install    # Install npm dependencies
$ npm run start  # Start the Webpack dev server
  • From a separate terminal, run the template's Streamlit app:
$ cd template
$ . venv/bin/activate  # activate the venv you created earlier
$ pip install -e . # install template as editable package
$ streamlit run my_component/example.py  # run the example
  • If all goes well, you should see something like this: Quickstart Success
  • Modify the frontend code at my_component/frontend/src/MyComponent.tsx.
  • Modify the Python code at my_component/__init__.py.

Examples

See the template-reactless directory for a template that does not use React.

See the examples directory for examples on working with pandas DataFrames, integrating with third-party libraries, and more.

Community-provided Templates

These templates are provided by the community. If you run into any issues, please file your issues against their repositories.

Contributing

If you want to contribute to this project, ./dev.py script will be helpful for you. For details, run ./dev.py --help.

More Information

More Repositories

1

streamlit

Streamlit β€” A faster way to build and share data apps.
Python
35,328
star
2

demo-self-driving

Streamlit app demonstrating an image browser for the Udacity self-driving-car dataset with realtime object detection using YOLO.
Python
1,190
star
3

llm-examples

Streamlit LLM app examples for getting started
Python
596
star
4

streamlit-example

Example Streamlit app that you can fork to test out share.streamlit.io
Python
325
star
5

demo-uber-nyc-pickups

A Streamlit demo to interactively visualize Uber pickups in New York City
Python
315
star
6

demo-face-gan

A demonstration of using a live Tensorflow session to create an interactive face-GAN explorer.
Python
294
star
7

app-starter-kit

Streamlit App Starter Kit helps kick start your Streamlit app creation.
Python
181
star
8

docs

Source code for the Streamlit Python library documentation
JavaScript
115
star
9

release-demos

Python
111
star
10

gsheets-connection

Python
106
star
11

snowflake-arctic-st-demo

Example repository for running Snowflake Arctic on Streamlit
Python
86
star
12

example-app-langchain-rag

Streamlit app demonstrating using LangChain and retrieval augmented generation with a vectorstore and hybrid search
Python
85
star
13

30days

#30DaysOfStreamlit is a 30-day social challenge for you to build and deploy Streamlit apps.
Python
79
star
14

example-app-pdf-report

πŸŽ“ Diploma PDF Generator
Python
63
star
15

example-app-bert-keyword-extractor

Python
63
star
16

roadmap

A public roadmap for Streamlit
Python
62
star
17

cookbook

This repository shares recipes on building Streamlit apps with various tools.
Python
57
star
18

StreamlitLangChain

Python
56
star
19

snowflake-usage-app

A Streamlit app that provides insights on your Snowflake account usage.
Python
56
star
20

30days-i18n

Python
54
star
21

example-app-time-series-annotation

Python
48
star
22

example-app-commenting

A Streamlit app to show how you can easily empower viewers to comment and collaborate on your app using a commenting component. The comments are hosted on a Google Sheets.
Python
48
star
23

example-app-editable-dataframe

This is a demo of a dataframe with editable cells, powered by `streamlit-aggrid` from Pablo Fonseca. You can edit the cells by clicking on them and then export your selection to a csv file! 🎈
Python
43
star
24

hello

Python
38
star
25

example-app-csv-wrangler

Python
38
star
26

example-app-bug-report

Python
30
star
27

example-app-ab-testing

Python
27
star
28

example-app-twitter-analyzer

Python
25
star
29

files-connection

Python
24
star
30

demo-deepdream

A Streamlit demo demonstrating the Deep Dream technique. Adapted from the TensorFlow Deep Dream tutorial.
Python
23
star
31

example-app-image-comparison

Python
18
star
32

example-app-invoice-generator

HTML
17
star
33

example-app-interactive-table

Python
16
star
34

example-app-zero-shot-text-classifier

Python
16
star
35

data_sources_app

An app that makes it easy to connect to a user's data warehouse and make a dashboard out of it.
Python
15
star
36

mintaka

TypeScript
15
star
37

theming-showcase-blue

Showcase app for Theming (Custom Theme, Blue)
Python
13
star
38

example-app-crypto-dashboard

Python
13
star
39

example-app-streamlit-codex

Python
12
star
40

links

Python
12
star
41

emoji-shortcodes

App showing all the emoji shortcodes supported by Streamlit
Python
12
star
42

theming-showcase

Showcase app for Theming (Light Theme)
Python
12
star
43

streamlit-hello

The App you get when you run `streamlit hello` extracted as its own app.
Python
11
star
44

streamlit-app-action

Simple GitHub Action workflows for validating a Streamlit app
Python
11
star
45

example-app-material-UI-button-creator

Design your Material-UI buttons, add clickable hyperlinks, integrate them in your Streamlit apps! 🎈
Python
10
star
46

example-app-download

Python
9
star
47

example-app-cv-model

Computer Vision app
Python
8
star
48

example-app-speech-to-text-transcription

Python
8
star
49

demo-streamlit-shap

Python
7
star
50

figma-to-streamlit

Prototype plugin to turn Figma components into st code snippets
TypeScript
7
star
51

example-app-dbt

Python
7
star
52

streamlit-ketcher

Chemical molecule custom component for Streamlit apps
TypeScript
7
star
53

blog-image-generator

Streamlit app that generates SVGs for use in our blog
Python
6
star
54

core-previews

App used to preview Streamlit Core PRs inside S4T
Python
6
star
55

example-app-cohort-analysis

Python
6
star
56

mol-demo

Python
5
star
57

snowflake-double-blind-demo

An example Streamlit app that demonstrates using Snowflake to join two datasets that use obfuscated IDs for data security
Python
5
star
58

static-file-serving-demo

Python
4
star
59

demo-pydeck-maps

A Streamlit app demonstrating usage of the pydeck library to display geospacial data
Python
4
star
60

Interactive-Data-Explorer

Python
4
star
61

example-data

Data files used in "streamlit hello"
3
star
62

theming-showcase-green

Showcase app for Theming (Custom Theme, Green)
Python
3
star
63

st-issues

Central repo to reproduce bugs
Python
3
star
64

theming-showcase-dark

Showcase app for Theming (Dark Theme)
Python
3
star
65

example-app-QA-generator

Python
3
star
66

blank-app-template

Python
3
star
67

chatbot-template

Python
3
star
68

basic-template

Python
3
star
69

30days-spanish

#30DaysOfStreamlit es una competencia de 30 dΓ­as para construir y desplegar aplicaciones hechas con Streamlit.
Python
2
star
70

arrow-js

A fork of `[email protected]` that fixes `BigInt64Array` issue in Safari.
JavaScript
2
star
71

demo-culture-map

Python
2
star
72

example-app-document-anonymizer

Python
2
star
73

cloud-example-apps

Python
2
star
74

movies-dataset-template

Python
2
star
75

GDP-Dashboard

Python
2
star
76

Inventory-Tracker

Python
2
star
77

example-app-file-converter

Python
1
star
78

30days-polish

Python
1
star
79

hpe-meetup-demo

Python
1
star
80

example-app-reddit

Python
1
star
81

demo-tab-container

Demo app to showcase the new st.tabs component
Python
1
star
82

Support-Ticket-Workflow

Python
1
star
83

gdp-dashboard-template

Python
1
star
84

inventory-tracker-template

Python
1
star