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
Vertical alignment for columns #3052
Comments
Hi, has there been any update on this feature? I am looking for something similar. |
same features needed, any update? |
Indeed -- I'm looking for the same functionality. Any updates? |
Would love this feature, will stay tuned! |
Any updates? |
Any updates? Really need this haha |
Hey all! We'll be working on layout options this summer and we definitely want to improve support for alignment. Don't know yet in detail how it will work, but we are all very aware of the pain to align things inside of columns! ;) |
Thanks @jrieke! I was just experience the same issue, so wanted to share my example too as another use case I'm aligning text/numbers/charts across columns and would like for them to all stay in a consistent row By the way, I think I could do the text/number part with a dataframe, but it doesn't solve the chart piece. I tried containers too and didn't have any luck
Output: |
I'd love to be able to "center" an item in a column vertically. Is there already a workaround to achieve this? Otherwise I'll hope that the summer updates will help with this as well :). |
@Khalilsqu you can't yet, that's why people are requesting that feature here. The request seems to be in the process from the streamlit team, but maybe someone can shine more light on where that stands/an ETA. I've only found workarounds for table-like data, using st.dataframe or st.table, or creating a HTML table (and then using st.markdown(, allow_unsafe_html=True). For text boxes and drop downs, I'd be curious if anyone's found a good solution too - I've just done something like inserting st.write('') to force a extra space in one of the columns. |
@msquaredds Thanks a lot for your answer. This is really unfortunate!! |
We are desperately waiting for this feature. Is there an ETA for this issue? |
The alignment method can be controlled using CSS styles. import streamlit as st
from PIL import Image
left, right = st.columns(2)
with left:
st.markdown("""
# Hello
## It is n awesome app
""")
with right:
st.image("https://cataas.com/cat")
st.write(
"""<style>
[data-testid="stHorizontalBlock"] {
align-items: center;
}
</style>
""",
unsafe_allow_html=True
) |
The above works fine for text and images, but we still would like to see the possibility to align other streamlit objects like buttons and text inputs. |
@carolinedlu did this enhancement not get past the "added-voting-callout" stage last year? |
I've added this in my column, just before the streamlit object. This is far from pixel-perfect but was the best/only option I could find without affecting every reference of that object's class. |
Still eagerly awaiting this function... |
grid = st.columns([3, 2, 2, 2])
grid[0].text("column 1")
grid[1].text("column 2")
grid[2].text("column 3")
grid[3].text('column 4')
for i in range (10):
grid = st.columns([3, 2, 2, 2])
grid[0].text_input("inmput", "input", key= f'input_text_row{i}',label_visibility="collapsed", disabled=True)
grid[1].selectbox("sel", ["a", "b", "c"] , key=f'input_sel_row{i}', label_visibility="collapsed")
grid[2].button('button', key=f'button_row{i}')
grid[3].markdown('This is a long line that will wrap if the screen is not wide') |
Having |
Hey all! We started building an early prototype for this feature. It simply adds a parameter I also added a few of the examples above to the demo app, thanks a lot to everyone who provided one! ❤️ We're still iterating on this since it doesn't yet solve all problems (especially aligning widgets with different sizes); see comments in the demo app. But if you give the wheel file a spin and have feedback, please let us know here! Btw re grid: there's a grid layout in streamlit-extras that you can give a try. We might also integrate something like this into Streamlit in the future but I don't have a timeline yet. |
Problem
As a user, I'd like to have the ability to vertically align within a container. While vertical alignment is not a problem in single columns, if there are 2 columns side by side then not having vertical alignment makes the contents look off.
Code to repro
Adding padding artificially somewhat mitigates the issue but it is not a perfect solution either
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.
The text was updated successfully, but these errors were encountered: