Hello Streamlit community! Iβm excited to introduce Streamlit Configurator β a declarative & modular way to build Streamlit apps. Instead of manually defining every component, you can structure pages effortlessly, while enjoying powerful state management and reusable layouts.
Key Features
Declarative Layouts β Use ComponentConfig & PageConfig to structure pages without repetitive code. Robust State Management β Preserve values across page refreshes with PlaceholderValue. Reusable Components β Define UI once and reuse it across multiple pages. Seamless Integration β Works alongside native Streamlit calls, so you can still use custom functions.
@Frunky Looks pretty useful, and will help separate UI config and rendering from business logic. It appears that it eliminates those nasty callbacks.
Can you clarify, if I had multiple page containers, say main_left and main_right, that I can use PageRenderer.render_layout to render the provided config into those page containers? E.g. :
with main_left:
# Assume we have a list of component configurations.
PageRenderer().render_layout(main_left_configs)
Currently, I donβt recommend directly using PageRenderer().render_layout() to render multiple independent page containers (such as your examples main_left and main_right). Unlike render_page, the render_layout method doesnβt contain page-specific configurations, and directly using it might lead to keyword generation errors.
Instead, I recommend structuring your configurations using the following approach:
Additionally, based on your naming, I suspect you might be looking for the functionality of st.columns . If thatβs the case, you could also structure it like this:
To be completely honest, I feel there is still considerable room for improvement in the design of PageRenderer. If you have any specific usage scenarios or suggestions about areas you find particularly awkward, please share them. Your feedback would greatly assist me in refining and improving the design!
Quick update: Iβve just realized thereβs a bug with the suggested approach I provided earlier. Currently, the length of main_left_configs must exactly match the length of main_right_configs, or it will raise an error.
Iβll address this issue ASAP.
Hi @Frunky, great project, thanks!
I want to know if you have some suggestion regarding the use the state management for the data_editor component, giving that it outputs something different than the edited dataframe itself.
For example, I mannaged to build this page. When I edit the dataframe while in-page it shows the right edits below. I can even import the edited dataframe from another page and it comes right.
But if I switch to another page and come back, it restart to initial df value.
This wonβt happen with other components like st.text_input (like in your app docs), where it stays the same cross-page.
Any hints on how to preserve the edited state?
Thanks in advance
Unfortunately, Iβm encountering the same challenge youβve described. Initially, the design of st_configurator assumed that the value saved by a Streamlit component using a key would be identical to the value returned by that component. However, the behavior of st.data_editor clearly deviates from this assumptionβthe returned value differs from what Streamlit stores internally with its key mechanism.
Since the demonstrated approach relies heavily on this assumption, it becomes challenging to achieve consistent cross-page state management with st.data_editor in the current design.
Iβll try to explore this further and see if I can find an alternative solution or provide improvements in the design to better support such scenarios. Meanwhile, if you have additional insights or suggestions based on your experience, Iβd appreciate hearing them!
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking βAccept allβ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.