pythonstreamlit

Streamlit how to display buttons in a single line


Hi all I am building a simple web app with streamlit in python. I need to add 3 buttons but they must be on the same line.

Obviously the following code puts them on three different lines

st.button('Button 1')
st.button('Button 2')
st.button('Button 3')

Do you have any tips?


Solution

  • Apparently this should do it

    col1, col2, col3 = st.columns([1,1,1])
    
    with col1:
        st.button('1')
    with col2:
        st.button('2')
    with col3:
        st.button('3')