A declarative and modular approach to building Streamlit apps
Project description
Streamlit Configurator
A declarative and modular approach to building Streamlit applications. Streamlit Configurator allows you to define UI components and layouts in a structured, reusable manner—eliminating repetitive Streamlit calls, improving maintainability, and enabling robust state management.
Contents
- Features
- Installation
- Quick Start
- Basic Usage
- Advanced Usage
- Example Pages
- License
- Contact & Contributing
Features
- Declarative Layouts: Use
ComponentConfigandPageConfigto define pages in a more descriptive style—no need to manually chain together multiple Streamlit calls. - Robust State Management: Utilize placeholders (
PlaceholderValue) to seamlessly store and retrieve data across page refreshes or navigations. - Reusable Configurations: Once you define a component or layout, you can reuse it across different pages, ensuring consistency and reducing code duplication.
- Integration & Compatibility: Works alongside native Streamlit calls. You can still write custom functions or direct Streamlit code where it makes sense.
- Scalable Architecture: As your app grows, define new placeholders or restructure layouts without rewriting large sections of code.
Installation
From PyPI (Upcoming / Planned)
Streamlit Configurator is available on PyPI. You can install it with:
pip install st-configurator
From Source (Current)
- Clone or download this repository.
- Navigate to the project's root directory.
- Install using pip:
pip install .
- Make sure Streamlit is installed:
pip install streamlit
Quick Start
Below is a minimal example showing how to set up a page with Streamlit Configurator.
import streamlit as st
from st_configurator import ComponentConfig, PageConfig, PageRenderer
from st_configurator.placeholder import Placeholder, PlaceholderValue
# 1. Define a custom placeholder class to hold your state
class MyPlaceholder(Placeholder):
NAME = PlaceholderValue(default="Guest")
# 2. Create a Streamlit component config (e.g., a text input)
name_input_config = ComponentConfig(
component=st.text_input,
args=("What's your name?",),
kwargs={"value": MyPlaceholder.NAME},
result_key=MyPlaceholder.NAME
)
# 3. Define a page config that includes this component
page_config = PageConfig(
page_tag="HomePage",
body=[name_input_config]
)
# 4. Render the page
PageRenderer().render_page(page_config)
- Run your script with:
streamlit run your_script.py
- Interact with the text input, navigate to other pages (if any), and come back. Notice the placeholder value persists.
Basic Usage
- Define Placeholders: Inherit from
Placeholderand declarePlaceholderValuesfor any data you need to persist. - Create Components: Use
ComponentConfigto wrap any Streamlit callable (e.g.,st.button,st.text_input). Pass placeholders or default values asargsorkwargs, and capture outputs by assigningresult_key. - Assemble Pages: Group components in a PageConfig. You can place some components in body and others in sidebar.
- Render: Call
PageRenderer().render_page(my_page_config)to display your page.
Advanced Usage
- Conditional Rendering: Add a
conditionto anyComponentConfigto selectively display or hide it based on a placeholder's boolean value (or the returned value of another component). - Nested Layouts: Use
childrenin aComponentConfigfor layout containers likest.columnsorst.tabs. - Persistence: If you need a placeholder to remain locked once it changes, set
persist=True. The new value overrides the default permanently, ignoring subsequent resets. - Global Scope: Set
global_scope=Truefor placeholders that are shared across all pages.
Example Pages
A more detailed set of usage examples and component demonstrations can be found in the example/ directory. To see them in action, run:
streamlit run example/main.py
You'll find multiple pages illustrating:
- Placeholder usage
- Declarative layout building
- Conditional rendering
- Nested containers and more
Each page includes commentary and code samples demonstrating how to use Streamlit Configurator's API.
License
This project is licensed under the terms of the LICENSE file.
Contact & Contributing
Contributions, bug reports, and feature requests are welcome! Feel free to open an issue or submit a pull request. If you find this project useful, please consider giving a star ⭐ on GitHub to support its continued development.
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 st_configurator-0.1.0b1.tar.gz.
File metadata
- Download URL: st_configurator-0.1.0b1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4eadb3a6eb19d8014ac11e6e075b668fabab5b38b05a442e23c59d6eeff0ddfb
|
|
| MD5 |
aca65666c3974c7fced60fe2ffdff44e
|
|
| BLAKE2b-256 |
0f21d1d815b057e6f6fe8635bd8f0e311316b88883167e326704c99a3f42f239
|
Provenance
The following attestation bundles were made for st_configurator-0.1.0b1.tar.gz:
Publisher:
python-publish.yml on FrunkyLiu/Streamlit-Configurator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
st_configurator-0.1.0b1.tar.gz -
Subject digest:
4eadb3a6eb19d8014ac11e6e075b668fabab5b38b05a442e23c59d6eeff0ddfb - Sigstore transparency entry: 171056301
- Sigstore integration time:
-
Permalink:
FrunkyLiu/Streamlit-Configurator@9dfa4b4fbd48a975c3ef0d4de7934ee15e567453 -
Branch / Tag:
refs/tags/v0.1.0b - Owner: https://github.com/FrunkyLiu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9dfa4b4fbd48a975c3ef0d4de7934ee15e567453 -
Trigger Event:
release
-
Statement type:
File details
Details for the file st_configurator-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: st_configurator-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f84efddd66a0ec0be33e4a159b4e1fd90c113f62de7f008e7dcf70d058a7587
|
|
| MD5 |
45d3b1c44b09a677f88856f532ee34ed
|
|
| BLAKE2b-256 |
ff92a702303eb087a37b3d36f9ed3132dcd6d45fd67f364e19d1ce57aabdf6ff
|
Provenance
The following attestation bundles were made for st_configurator-0.1.0b1-py3-none-any.whl:
Publisher:
python-publish.yml on FrunkyLiu/Streamlit-Configurator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
st_configurator-0.1.0b1-py3-none-any.whl -
Subject digest:
2f84efddd66a0ec0be33e4a159b4e1fd90c113f62de7f008e7dcf70d058a7587 - Sigstore transparency entry: 171056304
- Sigstore integration time:
-
Permalink:
FrunkyLiu/Streamlit-Configurator@9dfa4b4fbd48a975c3ef0d4de7934ee15e567453 -
Branch / Tag:
refs/tags/v0.1.0b - Owner: https://github.com/FrunkyLiu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9dfa4b4fbd48a975c3ef0d4de7934ee15e567453 -
Trigger Event:
release
-
Statement type: