💊 A Streamlit component to show clickable pills/badges
Project description
streamlit-pills 💊
A Streamlit component to show clickable pills/badges.
This custom component works just like st.selectbox
but shows the options as clickable
pills. It's nice to show the user upfront what they can select, without going through a
dropdown.
💊 Demo app 💊
Installation
pip install streamlit-pills
Usage
from streamlit_pills import pills
selected = pills("Label", ["Option 1", "Option 2", "Option 3"], ["🍀", "🎈", "🌈"])
st.write(selected)
See the demo app for a detailed guide!
Development
Note: you only need to run these steps if you want to change this component or contribute to its development!
Setup
First, clone the repository:
git clone https://github.com/jrieke/streamlit-pills.git
cd streamlit-pills
Install the Python dependencies:
poetry install
And install the frontend dependencies:
cd streamlit_pills/frontend
npm install
Making changes
To make changes, first go to streamlit_pills/__init__.py
and make sure the
variable _RELEASE
is set to False
. This will make the component use the local
version of the frontend code, and not the built project.
Then, start one terminal and run:
cd streamlit_pills/frontend
npm start
This starts the frontend code on port 3001.
Open another terminal and run:
cp demo/streamlit_app.py .
poetry shell
streamlit run streamlit_app.py
This copies the demo app to the root dir (so you have something to work with and see
your changes!) and then starts it. Now you can make changes to the Python or Javascript
code in streamlit_pills
and the demo app should update automatically!
If nothing updates, make sure the variable _RELEASE
in streamlit_pills/__init__.py
is set to False
.
Publishing on PyPI
Switch the variable _RELEASE
in streamlit_pills/__init__.py
to True
.
Increment the version number in pyproject.toml
. Make sure the copy of the demo app in
the root dir is deleted or merged back into the demo app in demo/streamlit_app.py
.
Build the frontend code with:
cd streamlit_pills/frontend
npm run build
After this has finished, build and upload the package to PyPI:
cd ../..
poetry build
poetry publish
Changelog
0.4.0 (March 24, 2023)
- Added Multi-Select
- Added Centered Mode
0.3.0 (November 22, 2022)
- Added
label_visibility
parameter to hide the label.
0.2.0 (November 22, 2022)
- Added
format_func
parameter to allow formatting the pill texts.
0.1.2 (November 22, 2022)
- First functioning release.
Project details
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
Hashes for streamlit_pills_multiselect-0.6.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca4cc370c08b4bd6a91395ca0fa59414fe41ef5aa068a24fba8d4b81803512fd |
|
MD5 | d52f01577cf2d978db98afbb5303ebf2 |
|
BLAKE2b-256 | 8dabac6326a6b37d0382daec971ce97e6075820471481f36c47ebf4e2790a551 |
Hashes for streamlit_pills_multiselect-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b551692a2f94459ab90a821a4402825c68bd0643780eb52a9c9a289b1009f6e |
|
MD5 | d4bc0173360c32dbb4ec46c8e3d4fb28 |
|
BLAKE2b-256 | 42addd8cdd95485aee33ace4399f20f23e4276c6c2bbeb9d8dd6f1ececdf9c8c |