Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center Streamlit Button

How do I center a button with Streamlit so that the button is still clickable? Here is a small example for a button that returns random numbers:

 import streamlit as st 
 import numpy as np

 if st.button('Click'): 
     rand = np.random.standard_normal()
     st.write(str(rand))

I've seen solutions with markdown for a title, but not for an interactive element like a button.

like image 872
jkortner Avatar asked Feb 26 '20 10:02

jkortner


2 Answers

col1, col2, col3 = st.beta_columns(3)
if col2.button('Click'):
    st.write('hello')
like image 103
Michael Hayman Avatar answered Sep 21 '22 15:09

Michael Hayman


Right now that’s not supported in Streamlit, but we are working on it (see our Roadmap for more info). Feel free to add your ideas to Customizable Layout for Streamlit discussion.

And thanks for using Streamlit!

like image 44
Henrikh Kantuni Avatar answered Sep 25 '22 15:09

Henrikh Kantuni