Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_number_controller-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_number_controller-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_number_controller-0.1.0.tar.gz.

File metadata

File hashes

Hashes for streamlit_number_controller-0.1.0.tar.gz
Algorithm Hash digest
SHA256 847ab7f0069600e8373204df7f67a55fc6b70a5c5ed2b43fb732e68855fc25d5
MD5 00c542d6ccad85d1382d84ee4ebda6c8
BLAKE2b-256 7cde9c2c765c28e2ae235330d6ee75e6a45e283ddfd1df838d405d9ab690c27f

See more details on using hashes here.

File details

Details for the file streamlit_number_controller-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_number_controller-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bb9671736b8c4495fd081f947b2605f569a280e3baa35364a0c37bc49ced80b
MD5 fb0a46830c436f4753b6ea9551ba507d
BLAKE2b-256 ddcce3389c8e95aa832dc51e52dd4ddbebc74529a2ad360b1985a646f5efe059

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page