Streamlit component that allows you to render Bokeh charts
Project description
streamlit-bokeh
A lightweight Python package that seamlessly integrates Bokeh plots into Streamlit apps, allowing for interactive, customizable, and responsive visualizations with minimal effort.
Filing Issues
Please file bug reports and enhancement requests through our main Streamlit repo.
🚀 Features
- Effortlessly embed Bokeh figures in Streamlit apps.
- Responsive layout support with
use_container_width. - Customizable themes (
streamlit(which supports both light and dark mode) or Bokeh Themes)
📦 Installation
uv pip install streamlit-bokeh
Ensure you have Streamlit and Bokeh installed as well:
uv pip install streamlit bokeh
🛠️ Development
Prerequisites
- Python 3.10–3.13
- Node.js 24.x.y (see
.nvmrc) - uv (fast Python package manager)
1) Create and activate a virtual environment
uv venv .venv
source .venv/bin/activate
2) Install Python dependencies from pyproject.toml
# Minimal runtime install (editable)
uv pip install -e .
# Recommended for development (includes tests/tools)
uv pip install -e ".[devel]"
3) Install and build the frontend
cd streamlit_bokeh/frontend
corepack enable
yarn install
yarn build # one-time build to produce frontend/build assets
# Optional: frontend dev server
# Use `yarn dev:v2` to utilize the Custom Component v2 frontend (recommended).
# Use `yarn dev:v1` to utilize the Custom Component v1 frontend (legacy).
yarn dev:v2
4) Run a local demo
streamlit run ./e2e_playwright/bokeh_chart_basics.py
5) Run tests
Python end-to-end tests (Playwright):
# Build the package
uv build
# Install the test dependencies
uv pip install -r e2e_playwright/test-requirements.txt
# Install browsers (first time only)
python -m playwright install --with-deps
# Run tests
pytest e2e_playwright -n auto
Frontend tests and type checks:
cd streamlit_bokeh/frontend
yarn test
yarn typecheck
6) Build the Python package (optional)
uv build
ls dist/
💡 Usage
Here's how to integrate a simple Bokeh line plot into your Streamlit app:
from bokeh.plotting import figure
from streamlit_bokeh import streamlit_bokeh
# Data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
# Create Bokeh figure
YOUR_BOKEH_FIGURE = figure(title="Simple Line Example",
x_axis_label="x",
y_axis_label="y")
YOUR_BOKEH_FIGURE.line(x, y, legend_label="Trend", line_width=2)
# Render in Streamlit
streamlit_bokeh(YOUR_BOKEH_FIGURE, use_container_width=True, theme="streamlit", key="my_unique_key")
⚙️ API Reference
streamlit_bokeh(figure, use_container_width=False, theme='streamlit', key=None)
Parameters:
figure(bokeh.plotting.figure): The Bokeh figure object to display.use_container_width(bool, optional): Whether to override the figure's native width with the width of the parent container. This isTrueby default.theme(str, optional): The theme for the plot. This can be one of the following strings:"streamlit"(default): Matches Streamlit's current theme.- A Bokeh theme name including:
"caliber""light_minimal""dark_minimal""contrast"
key(str, optional but recommended): An optional string to give this element a stable identity. If this isNone(default), this element's identity will be determined based on the values of the other parameters.
🖼️ Example
streamlit run app.py
Where app.py contains:
import streamlit as st
from bokeh.plotting import figure
from streamlit_bokeh import streamlit_bokeh
# Sample Data
x = [1, 2, 3, 4, 5]
y = [2, 4, 8, 16, 32]
# Create Plot
p = figure(title="Exponential Growth", x_axis_label="x", y_axis_label="y")
p.line(x, y, legend_label="Growth", line_width=3, color="green")
# Display in Streamlit
streamlit_bokeh(p, use_container_width=True, key="plot1")
📚 Versioning
We designed the versioning scheme for this custom component to mirror the Bokeh version with the exception of the patch number. We reserve that so we can make bug fixes and new (mostly compatible) features.
For example, 3.6.x will mirror a version of Bokeh that's 3.6.y.
📝 Contributing
Feel free to file issues in our Streamlit Repository.
Contributions are welcome 🚀, however, please inform us before building a feature.
📄 License
This project is licensed under the Apache 2.0.
🙋 FAQ
Q: Can I embed multiple Bokeh plots on the same page?
- A: Yes! Just make sure each plot has a unique
key.
Q: Does it support Bokeh widgets?
- A: Currently,
streamlit-bokehfocuses on plots. For widget interactivity, consider combining with native Streamlit widgets.
Q: How do I adjust the plot size?
- A: Use
use_container_width=Truefor responsive sizing, or manually setplot_widthandplot_heightin your Bokeh figure.
Happy Streamlit-ing! 🎉
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_bokeh-3.9.0.tar.gz.
File metadata
- Download URL: streamlit_bokeh-3.9.0.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63d9786e6682ab9fe73726e7902b62a5566fe4c49bb64eb08baec8e212e24b27
|
|
| MD5 |
760078bb6eb04b2370158a6f10308504
|
|
| BLAKE2b-256 |
ac7dbac890a52cd93499f956982b8002bf8b97a06a9aec82bf07d1f67e62f2c7
|
Provenance
The following attestation bundles were made for streamlit_bokeh-3.9.0.tar.gz:
Publisher:
release.yml on streamlit/streamlit-bokeh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_bokeh-3.9.0.tar.gz -
Subject digest:
63d9786e6682ab9fe73726e7902b62a5566fe4c49bb64eb08baec8e212e24b27 - Sigstore transparency entry: 1117747041
- Sigstore integration time:
-
Permalink:
streamlit/streamlit-bokeh@6edf013426977e293cf3fd359102a0916f1b4373 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/streamlit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6edf013426977e293cf3fd359102a0916f1b4373 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file streamlit_bokeh-3.9.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_bokeh-3.9.0-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e884d059fb1f894cac705176a734c54f5aa949b1f29047e0a92a5fe51a166ee1
|
|
| MD5 |
42888a16afc87a5421c09b776427b1a8
|
|
| BLAKE2b-256 |
850a6905fe9ce5ae8302540b09b16d990e1ae0460715a29b19b09ee996779ec0
|
Provenance
The following attestation bundles were made for streamlit_bokeh-3.9.0-py3-none-any.whl:
Publisher:
release.yml on streamlit/streamlit-bokeh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_bokeh-3.9.0-py3-none-any.whl -
Subject digest:
e884d059fb1f894cac705176a734c54f5aa949b1f29047e0a92a5fe51a166ee1 - Sigstore transparency entry: 1117747161
- Sigstore integration time:
-
Permalink:
streamlit/streamlit-bokeh@6edf013426977e293cf3fd359102a0916f1b4373 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/streamlit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6edf013426977e293cf3fd359102a0916f1b4373 -
Trigger Event:
pull_request
-
Statement type: