Horizontal layout

Summary

Most posts suggest using st.columns for implementing horizontal layouts. However, according to Horizontal Layout | Components | Vaadin Docs the layour should define its width and height automatically, determined by the components it contains.

What I’d like to do eg. is to place a button horizontally adjacent to a text. Since I don’t know the width of the text, I can’t use st.columns to adjust the columns width.

I see now there’s an open issue Compact layout and compact widgets to get the most from the available screen space · Issue #6867 · streamlit/streamlit · GitHub

Anybody has a workaround?

thanks

Hi @dpinol

The simplest approach to do this is indeed via st.columns() and you can use relative width to determine the width of the columns such as:

col1, col2 = st.columns([3, 1])

as shown in the Streamlit Docs page

Hope this helps!

thanks, the problem I have is “Since I don’t know the width of the text, I can’t use st.columns to adjust the columns width.”

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.