-
Notifications
You must be signed in to change notification settings - Fork 4k
Set use_container_width=True by default for st.dataframe and st.data_editor
#10434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set use_container_width=True by default for st.dataframe and st.data_editor
#10434
Conversation
use_container_width=True by default for st.dataframe and st.data_editoruse_container_width=True by default for st.dataframe and st.data_editor
…container-width-true-for-dataframe
use_container_width=True by default for st.dataframe and st.data_editoruse_container_width=True by default for st.dataframe and st.data_editor
…container-width-true-for-dataframe
|
I noticed the playwright snapshots for |
|
|
||
|
|
||
| st.header("Hide index parameter:") | ||
| st.dataframe(df, hide_index=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to pin the width for some of these tests instead of setting use_container_width=False?
I guess use_container_width=False will be replaced by width="content". Do you have a sense of which of these three is the most commonly used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to pin the width for some of these tests instead of setting use_container_width=False?
We have some dedicated tests for width=pixels here: https://github.com/streamlit/streamlit/blob/develop/e2e_playwright/st_dataframe_dimensions.py But from our adoption data, its not used a lot so I think its better to mostly test with use_container_width=True/False.
I guess use_container_width=False will be replaced by width="content". Do you have a sense of which of these three is the most commonly used?
We hope that width="stretch" would be the preferred option in most cases. But the data will eventually show us how many users are switching it to False / content again.
| st.dataframe(df) | ||
| st.dataframe(df, use_container_width=False) | ||
| st.dataframe(df, 250, 150) | ||
| st.dataframe(df, width=250) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know there is this test as well, I was just thinking it looks a bit odd to override the default setting in so many tests.
|
Just curious, we do expect |
Yes, the assumption is that stretch is the more commonly preferred setting for DataFrame.
Some of the tests overwrite it because we need a deterministic column width for our interactive dataframe e2e tests. For other tests, I just used |
We decided not to "grow" pinned/index columns since they look a bit better visually. This means that pinned columns will be sized based on their content, and other columns will take up the available space. |
That makes sense. I'm not so much concerned about test coverage, it would just be nice not to have all the overrides and have most tests use the default behaviour. But it's not a bit concern and keeping the snapshots small is a good counter reasoning. |
I noticed this in the prototype as well, I agree it looks funny when the index column grows large. |
This reverts commit a7b8b73.
|
This change dramatically changes the look of all of my existing streamlits. I respect the desire to move to this new default, but it is causing me to have to add "set_container_width=False" everywhere. it would be nice to add an option to the config file to set the default for this option. |
@rsheftel that's an interesting idea -- can you file an issue (enhancement)? We are currently working on providing more layout options. cc @jrieke |
Describe your changes
Configures
st.dataframeandst.data_editorto useuse_container_width=Trueas default (stretch the full container width) if the user does not provide awidthexplicitly.Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.