Skip to main content

A collection of Streamlit components that use or are inspired by the GOV.UK Design System

Project description

streamlit-gov-uk-components

A collection of Streamlit components that use or are inspired by the GOV.UK Design System

Installation

pip install streamlit-gov-uk-components

Available components

Usage

Checkbox (example)

Checkbox example
from streamlit_gov_uk_components import gov_uk_checkbox

selected = gov_uk_checkbox(
    label="Waste from animal carcasses",  # Label shown in browser
    id="waste-from-animal-carcasses",     # ID of checkbox in HTML
    key="waste-from-animal-carcasses",    # Streamlit component instance key
    default=True,                         # Initially selected?
)

Smaller checkbox (example)

Smaller checkbox example
from streamlit_gov_uk_components import gov_uk_checkbox_small

selected = gov_uk_checkbox_small(
    label="HM Revenue and Customs (HMRC)",  # Label shown in browser
    id="hmrc",                              # ID of checkbox in HTML
    key="hmrc",                             # Streamlit component instance key
    default=True,                           # Initially selected?
)

Checkbox list (example)

Smaller checkbox example
from streamlit_gov_uk_components import gov_uk_checkbox_list

selected = gov_uk_checkbox_list(
    # Tuple of (ID, label) pairs
    options=(
        ("waste-from-animal-carcasses", "Waste from animal carcasses"),
        ("waste-from-mines-or-quarries", "Waste from mines or quarries"),
        ("farm-or-agricultural-waste", "Farm or agricultural wastes"),
    ),
    key="waste",
    # Tuple of initially selected IDs
    default=("waste-from-animal-carcasses",),
)

Smaller checkbox list (example)

Smaller checkbox list example
from streamlit_gov_uk_components import gov_uk_checkbox_small_list

selected = gov_uk_checkbox_small_list(
    # Tuple of (ID, label) pairs
    options=(
        ("hm-revenue-and-customs", "HM Revenue and Customs (HMRC)"),
        ("employment-tribunal", "Employment Tribunal"),
        ("ministry-of-defence", "Ministry of Defence"),
        ("department-for-transport", "Department for Transport"),
    ),
    key="waste",
    # Tuple of initially selected IDs
    default=("hm-revenue-and-customs",),
)

Radio list (example)

Radio list example
from streamlit_gov_uk_components import gov_uk_radio_list

selected = gov_uk_radio_list(
    # Tuple of (ID, label) pairs
    options=(
        ("england", "England"),
        ("scotland", "Scotland"),
        ("wales", "Wales"),
        ("northern-ireland", "Northern Ireland"),
    ),
    id="where-do-you-live",   # Base of HTML IDs for radios
    key="where-do-you-live",  # Streamlit component instance key
    default="england",        # Initially selected ID
)

Smaller radio list (example)

Radio list example
from streamlit_gov_uk_components import gov_uk_radio_small_list

selected = gov_uk_radio_small_list(
    # Tuple of (ID, label) pairs
    options=(
        ("monthly", "Monthly"),
        ("yearly", "Yearly"),
    ),
    id="filter",        # Base of HTML IDs for radios
    key="filter",       # Streamlit component instance key
    default="monthly",  # Initially selected ID
)

Local development

The examples serve as reasonable mini Streamlit applications that allow development of the components themselves. Two terminal session are typically needed.

One to run Streamlit itself...

pip install streamlit
STREAMLIT_GOV_UK_COMPONENTS_DEV=True streamlit run example_checkbox.py

... and one to run a development server that automatically recompiles and serves the HTML and Javascript of the front end of each component.

cd streamlit_gov_uk_components/frontend_checkbox
yarn install
./fix.sh
yarn run start

Releasing to PyPI

  1. Ensure that each frontend component has been built. Each frontend component must be built, not just those that have changed, since the production builds of each are not checked into the repository.

    cd streamlit_gov_uk_components/frontend_checkbox
    yarn install
    ./fix.sh
    yarn run build
    
  2. Ensure that there is a line in MANIFEST.in for each frontend component.

  3. Bump the version inside setup.py

  4. Commit with a Conventional Commit message with the bumped version, tag the commit with the bumped version, and push to GitHub.

    git add setup.py
    git commit -m "build(release): v0.0.4"
    git tag v0.0.4
    git push origin main --tags
    
  5. Build and release to PyPI

    pip install build twine
    rm -r -f build dist && python -m build && 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-gov-uk-components-0.0.11.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

streamlit_gov_uk_components-0.0.11-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file streamlit-gov-uk-components-0.0.11.tar.gz.

File metadata

  • Download URL: streamlit-gov-uk-components-0.0.11.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for streamlit-gov-uk-components-0.0.11.tar.gz
Algorithm Hash digest
SHA256 4d74fe2c446a1c1fd098e21ed9d232f7bc378eb4b6835cd8d27065bc232f9868
MD5 a168c7cb1139b8f085de8ad699749468
BLAKE2b-256 7d11a49836f75dfd87128d0210ef6e5cb2dd93095c3cd46acc9670f2ac6d47ad

See more details on using hashes here.

File details

Details for the file streamlit_gov_uk_components-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: streamlit_gov_uk_components-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for streamlit_gov_uk_components-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 7693d1dfc77488b5ce014c80e01cee82b313aa628ed2b4dfeb4ce32fb3e55337
MD5 591fcd6475421327edc441f02d50f3bc
BLAKE2b-256 d19383e3b1f216d51aeb43b66917ced4b5eb38ab9ed07cdc24b6dadd49a3d90b

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