Skip to main content

Streamlit Bridge PyPI License

Two Streamlit components that allow client side (javascript) to send data to the server side (python) and render HTML content without being processed by Markdown.

Introduction

These two components offer more flexibility in creating Streamlit applications by allowing you to easily incorporate HTML and JS.

Here are some examples:

  1. List of inline buttons Streamlit inline buttons

    import streamlit as st
    from st_bridge import bridge, html
    
    data = bridge("my-bridge", default="no button is clicked")
    
    html("""
    <button onClick="window.top.stBridges.send('my-bridge', 'button 1 is clicked')">Button 1</button>
    <button onClick="window.top.stBridges.send('my-bridge', 'button 2 is clicked')">Button 2</button>
    <button onClick="window.top.stBridges.send('my-bridge', 'button 3 is clicked')">Button 3</button>
    """)
    
    st.write(data)
    
  2. Timer

Installation

pip install streamlit-bridge

API

Bridge Component

def bridge(
    name: str,
    default: Optional[Any] = None,
    key: Optional[str] = None,
):
    """Create a new instance of "Streamlit Bridge", allowing call from the client to
    the server.

    Everytime JS client send data to the server, streamlit will trigger a rerun and the data
    is returned by this function.

    Args:
        name: unique name of the bridge to identify the bridge Javascript's call will send data to
        default: the initial return value of the component before the user has interacted with it.
        key: streamlit component's id
    """

To send data from the client to a corresponding bridge component with <bridge-name>, use the function: window.stBridges.send(<bridge-name>, <data>); or window.top.stBridges.send(<bridge-name>, <data>); if you are running it inside an component (i.e., running inside an iframe) or Streamlit Cloud. Note that window.top is important to access the stBridges variable stored in the top-most window by the bridge component.

HTML Component

def html(html: str, iframe: bool = False, key: Optional[str]=None) -> None:
    """Render HTML in Streamlit without being processed by Markdown.

    Args:
        html: HTML to render
        iframe: whether to render the HTML in an iframe or in the main document.
                By default streamlit component is rendered inside an iframe, so by
                setting it to false, we allow the HTML to rendered in the main document.
        key: streamlit component's id
    """
    pass

Development

  • To build a streamlit component after modifying them:
    • visiting their folder: st_bridge/<component>
    • run yarn install; yarn build
  • To test a component interactively, set _RELEASE = False in st_bridge/<component>.py and run streamlit run st_bridge/<component>.py
  • To release, build the streamlit components first, then run poetry publish --build.

Metadata

Release files for streamlit-bridge 1.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-bridge 1.1.8
File Size Uploaded
streamlit_bridge-1.1.8.tar.gz 2.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-bridge 1.1.8
File Interpreter ABI Platform
streamlit_bridge-1.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 4.6 MB

Release files / streamlit_bridge-1.1.8.tar.gz

Download URL streamlit_bridge-1.1.8.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
b056401a519fa34dfc7cb9d4b36aa38cc813652d212895f00681a19af8f6844e
BLAKE2b-256 checksum
How to use checksums
8378ee7e838a564f0eceb875f085741fdbc403a9320f35b48611645b19734992
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/24.3.0

Release files / streamlit_bridge-1.1.8-py3-none-any.whl

Download URL streamlit_bridge-1.1.8-py3-none-any.whl
Size 2.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
13e4c8e3e9936c58fb241e1d45378c1f66876f947f5c4e900793419deca57c85
BLAKE2b-256 checksum
How to use checksums
99148b46b0fe40cc5ac88d6313f050667752793dbbc57f5e8a12c16b4407e663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/24.3.0

Release history Release notifications | RSS feed

This release

1.1.8 This release

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page