Skip to main content

A simple clickable list component for streamlit

Project description

streamlit-clickable-list

See demo: https://demopy-6aplg2asvytivaazchhqbj.streamlit.app/

How to install

pip install streamlit-clickable-list

How to use

col1, col2 = st.columns([1, 1])
with col1:
  def on_click(name: str) -> None:
    print(f"clicked: {name}")
    st.session_state['clicked'] = name

  st.header("Clickable list:")
  clickable_list(["aaa", "bbb", "ccc"], on_click, key="clickable_list")

with col2:
  st.header("Result:")
  if "clicked" in st.session_state:
    st.write(f"Clicked: {st.session_state['clicked'] or 'none'}")

streamlit-clickable-list_demo

For the component development

Based on: https://docs.streamlit.io/develop/concepts/custom-components/intro

Set up

  • Set up python environment and dependencies
    • Used: v3.9
    • If you use uv, run:
      uv sync
      
  • Set up Node.js environment
    • Used v22.13.1
    • If you use nvm, run:
      nvm use
      
  • Set up node_modules
    cd frontend
    npm install
    

Run dev

  • Use dev mode
    • Edit streamlit_clickable_list/__init__.py
      -_RELEASE = True
      +_RELEASE = False
      
  • Run dev server
    cd frontend
    npm start
    
  • Run streamlit app
    streamlit run demo.py
    
    # with WSL
    streamlit run demo.py --server.fileWatcherType=poll --server.address=0.0.0.0
    
    • If you use uv, add uv run

Release to PyPI

  • Use release mode
    • Edit streamlit_clickable_list/__init__.py
      -_RELEASE = False
      +_RELEASE = True
      
  • Build react app
    cd frontend
    npm build
    
  • Run the app to check it in local
    streamlit run demo.py
    
    # with WSL
    streamlit run demo.py --server.fileWatcherType=poll --server.address=0.0.0.0
    
  • Update version
    • Edit pyproject.toml to change version
  • Build python
    • If you use uv, run:
      uv build
      
  • Push to GitHub (if you update README.md)
  • Publish to PyPI
    uv publish --token <PyPI token>
    
    • Check $HOME/.pypirc for <PyPI token>

Release to Streamlit Community Cloud

Only the first time:

To publish:

  • First, publish it to PyPI
    • Because the app in Streamlit Community Cloud uses the streamlit-clickable-list in PyPI
  • Generate requirement.txt
    • If you use uv, run:
      uv pip compile pyproject.toml > requirements.txt
      
  • Push github, then it will be deployed to Streamlit Community Cloud

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_clickable_list-0.1.1.tar.gz (405.0 kB view details)

Uploaded Source

Built Distribution

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

streamlit_clickable_list-0.1.1-py3-none-any.whl (408.1 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_clickable_list-0.1.1.tar.gz.

File metadata

File hashes

Hashes for streamlit_clickable_list-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ce4739ff733a7c988af3f052ac09e94148bc4ab458955ce0b48a4b7d5a872a1a
MD5 b605531fbdfb2d7029c41dc57111bf3a
BLAKE2b-256 a423c547fdcbd9144326d93e231f0d921e1d8f9e996151f21fe32a5c6ce89cd6

See more details on using hashes here.

File details

Details for the file streamlit_clickable_list-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_clickable_list-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6ae86bd7649f608580baa7a98891c029dceec4cf0655901b6609bacccf242d2
MD5 1a73c3ed5dc6d8b467fd5c8d287bd0bf
BLAKE2b-256 3f61ddc61b0bc4a8984f5e1690c51ba2758d812de940f68926d156464c71cf5e

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