A compact plus/minus number controller for Streamlit apps.
Project description
streamlit-number-controller
A compact plus/minus number controller for Streamlit apps.
import streamlit as st
from streamlit_number_controller import number_controller
value = number_controller(
title="Quantity",
min_value=0,
max_value=10,
default_value=1,
key="quantity",
minus_color="#ef4444",
plus_color="#2563eb",
minus_button_color="#fee2e2",
plus_button_color="#dbeafe",
)
st.write("Current value:", value)
Installation
pip install streamlit-number-controller
API
number_controller(
title: str,
min_value: int,
max_value: int,
default_value: int,
*,
key: str | None = None,
step: int = 1,
minus_icon: str = ":material/remove:",
plus_icon: str = ":material/add:",
minus_color: str | None = None,
plus_color: str | None = None,
minus_button_color: str | None = None,
plus_button_color: str | None = None,
) -> int
The controller stores its value in st.session_state, keeps the displayed value and returned value in sync, and clamps changes to min_value / max_value.
Development
Run the example app:
streamlit run examples/app.py
Build the package:
python -m build
Upload to TestPyPI:
python -m twine upload --repository testpypi dist/*
Upload to PyPI:
python -m twine upload dist/*
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 streamlit_number_controller-0.1.0.tar.gz.
File metadata
- Download URL: streamlit_number_controller-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
847ab7f0069600e8373204df7f67a55fc6b70a5c5ed2b43fb732e68855fc25d5
|
|
| MD5 |
00c542d6ccad85d1382d84ee4ebda6c8
|
|
| BLAKE2b-256 |
7cde9c2c765c28e2ae235330d6ee75e6a45e283ddfd1df838d405d9ab690c27f
|
File details
Details for the file streamlit_number_controller-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_number_controller-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bb9671736b8c4495fd081f947b2605f569a280e3baa35364a0c37bc49ced80b
|
|
| MD5 |
fb0a46830c436f4753b6ea9551ba507d
|
|
| BLAKE2b-256 |
ddcce3389c8e95aa832dc51e52dd4ddbebc74529a2ad360b1985a646f5efe059
|