Center button st.button

How to center the button ? thanks

1 Like

Hey @DATAtourism,

Have you seen this post that centres an image by using st.beta_columns ?

Happy Streamlit-ing!
Marisa

1 Like

Thanks @Marisa_Smith. Itā€™s really useful to me. Just putting it in a way easier to copy :stuck_out_tongue:

import streamlit as st 
import cv2 img = cv2.imread('photo.jpeg') 
st.image(img, use_column_width=True, caption='Random image for sizing') 
st.title("Off center :(") 
col1, col2, col3 = st.beta_columns([1,1,1])
col2.title("Centered! :)") 
col2.image(img, use_column_width=True)

Screenshot

1 Like

Lovely! Thanks @vijaysaimutyala

As far as I am aware, there is no conventional method for centering the button. However, I have discovered an easy cure. It is not the proper way, but it works.
You can experiment with the following:

col1, col2, col3 , col4, col5 = st.beta_columns(5)

with col1:
    pass
with col2:
    pass
with col4:
    pass
with col5:
    pass
with col3 :
    center_button = st.button('Button')