Is there a way to make a table of widgets?

I would like to have a button that has the following functionality:
Each time I click it, it creates a pair of widgets, a selectbox and a button right next to each other, the button next to the selectbox is deleting the selectbox and itself when clicked.
I had an idea of making each of these pairs a 1 by 2 table of widgets so that the button and selectbox would appear next to each other and would not drift apart.
Before that I tried using columns and got the following problem:

Is there any way to make such a table?

You need to create two columns separately for each row. Here is a simple example.

import streamlit as st

def remove_row(row):

if "rows" not in st.session_state:
    st.session_state.rows = []

add_button = st.button(label="Add")
if add_button:
    next_row = max(st.session_state.rows) + 1 if st.session_state.rows else 1

for row in st.session_state.rows:
    left, right = st.columns(2)
    left.selectbox(label=f"Test {row}", options="abcde")
        label="Remove", key=f"remove_{row}", on_click=remove_row, kwargs={"row": row}
1 Like

Thank you so much, it worked!
Is there any way to make the remove button work? It doesn’t work now.
Another problem I am facing is that whenever I click on remove or choose some option from the selectbox, the screen goes dark
Before I click something:

After clicking somthing inside this container:

An important mention is that the container of the upper buttons are not turning darker.

The Remove button works for me and I don’t see the screen going dark. But then your code seems to be different than mine so the behavior can also be different.

Ok thank you very much.

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