Skip to main content

streamlit-pills 💊

PyPI

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.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.

Metadata

Release files for streamlit-pills 0.3.0

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-pills 0.3.0
File Size Uploaded
streamlit-pills-0.3.0.tar.gz 696.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-pills 0.3.0
File Interpreter ABI Platform
streamlit_pills-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / streamlit-pills-0.3.0.tar.gz

Download URL streamlit-pills-0.3.0.tar.gz
Size 696.5 kB
Tags Source
SHA-256 checksum
How to use checksums
47668ad4fd8c137b203ee1aec9d9d44ed8b2ff7ded9f586984f204be2eac772f
BLAKE2b-256 checksum
How to use checksums
1baaffc0955bb8a553bd1e9e0adf0467f4d4f706c26925c73dfde6bab783645e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.15 CPython/3.9.12 Darwin/22.1.0

Release files / streamlit_pills-0.3.0-py3-none-any.whl

Download URL streamlit_pills-0.3.0-py3-none-any.whl
Size 706.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b66fdf7b1820c09b751a76ef1ae01ab93221d0c2c2d1cd489b711b9afaae0513
BLAKE2b-256 checksum
How to use checksums
b6bce5328adadf5479795d6c7cf30c3fb69dba818384b1d44b48562cc9b2e618
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.15 CPython/3.9.12 Darwin/22.1.0

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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