Streamlit custom component: DataTables (React) wrapper
Project description
st-datatables
Streamlit custom component wrapping DataTables for interactive dataframe display.
It is designed for tables that need row selection, action buttons, column visibility controls, scrolling, and HTML/SVG cells such as RDKit molecule structure drawings.
Installation
pip install st-datatables
Usage
import pandas as pd
import streamlit as st
from st_datatables import st_datatables
df = pd.DataFrame(
[
{"ID": "mol-1", "SMILES": "CCO", "MOLWT": 46.07},
{"ID": "mol-2", "SMILES": "c1ccccc1", "MOLWT": 78.11},
]
)
selected = st_datatables(
df=df,
id_col="ID",
orderable_cols=["MOLWT"],
searchable_cols=["ID", "SMILES"],
select="single",
key="molecule_table",
)
st.write(selected)
Molecule Structure Columns
Use html_cols or column_config when a column contains pre-rendered SVG or
HTML, for example RDKit SVG drawings.
selected = st_datatables(
df=df_with_structure_svg,
id_col="ID",
html_cols=["structure_svg"],
column_config={
"structure_svg": {
"html": True,
"width": 220,
"orderable": False,
"searchable": False,
},
"SMILES": {"mono": True},
"MOLWT": {"format": ".2f", "orderable": True},
},
rowHeight=220,
structure_img_width=200,
structure_img_height=200,
preserve_selection_on_rerun=True,
preserve_table_state=True,
key="molecule_table",
)
Returned Value
The component returns a dictionary containing selected rows and stable row IDs.
{
"rows": [...],
"indexes": [...],
"ids": [...],
"count": 1,
"event_id": "...",
"table_state": {...},
}
When an action button is clicked, the row data is returned with an action
field and _rowIndex.
Reset Selection
from st_datatables import reset_selection
if st.button("Reset"):
reset_selection("molecule_table")
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 st_datatables-0.1.1.tar.gz.
File metadata
- Download URL: st_datatables-0.1.1.tar.gz
- Upload date:
- Size: 558.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f84555949b3f15d74387f336ca5c3a726a7a3e7e2dcc4e65c6a64812faa79c28
|
|
| MD5 |
3c29b69abd4e9c159f89d6def900e9b8
|
|
| BLAKE2b-256 |
130433663a09e37626a98c0bb796b40dee8656b5b8c9422abf3ce522436fd7bd
|
File details
Details for the file st_datatables-0.1.1-py3-none-any.whl.
File metadata
- Download URL: st_datatables-0.1.1-py3-none-any.whl
- Upload date:
- Size: 563.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63d826dfa18d748df7cfde596a338470b25725d27174d66eb9a8b2f7725e7466
|
|
| MD5 |
0ffd2b49be6ff9c4c063eace0c7394fd
|
|
| BLAKE2b-256 |
ec290d7600dcccd0d0caceaece96bb18a71d102d10826b62669b3f5b62933bdd
|