https://github.com/vivien000/st-click-detector
https://github.com/vivien000/st-click-detector
streamlit
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/vivien000/st-click-detector
- Owner: vivien000
- License: mit
- Created: 2022-03-21T19:19:19.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-22T20:15:17.000Z (about 4 years ago)
- Last Synced: 2025-03-25T00:42:27.286Z (about 1 year ago)
- Topics: streamlit
- Language: Python
- Homepage:
- Size: 261 KB
- Stars: 64
- Watchers: 1
- Forks: 8
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# st-click-detector
`st-click-detector` is a [Streamlit](https://streamlit.io) component to display some HTML content and detect when hyperlinks are clicked on.

A more advanced example can be seen live [here](https://huggingface.co/spaces/vivien/semanticsearch).
## Installation
```bash
pip install st-click-detector
```
## Quickstart
Put your HTML content in a string and make sure that `` tags include an `id` (clicks on links without `id` will be ignored by the component)
```python
import streamlit as st
from st_click_detector import click_detector
content = """
"""
clicked = click_detector(content)
st.markdown(f"**{clicked} clicked**" if clicked != "" else "**No click**")
```
## Usage
**click_detector(html_content, key=None)**
Display HTML content and detect when links are clicked on
### Parameters
- `html_content` (str): content to display and from which clicks should be detected
- `key` (str or None): an optional key that uniquely identifies this component. If this is None, and the component's arguments are changed, the component will be re-mounted in the Streamlit frontend and lose its current state