How to have 2 rows of columns using st.beta_columns()

Hello! :smile:

Loving the st.beta_columns function so far! In order to present a better layout, instead of having a row of 4 columns (1x4), I’d like to break up the columns into two rows of two columns (2x2).

Sample code for 1x4:

col1, col2, col3, col4 = st.beta_columns(4)
with col1:
selected_col1 = st.multiselect(…)
with col2:
selected_col2 = st.multiselect(…)
with col3:
selected_col3 = st.multiselect(…)
with col4:
selected_col4 = st.multiselect(…)

I cannot make two consecutive calls of (to get 2x2):

col1, col2 = st.beta_columns(2)
col3, col4 = st.beta_columns(2)

Can someone please advise me on how to make multiple rows of columns possible? Thank you very much! :bowing_woman:

Hi @dashboard I think you only need 2 columns for what you want, but with two calls, something like this:

col1,col2=st.beta_columns(2)
with col1:
   something in row1..

with col2:
   something in row1..

with col1:
  something in row2..

with col2:
   something in row2..

That is amazing - exactly what I need. Thank you so much, @napoles3d ! :tada:

1 Like