Align to the right

given a widget, for example st.button, how can i align it to the right?
instead of default left


1 Like

Hi @iuiu ,

Please reference st.columns from the streamlit docs.


thanks for the quick answer.

I don’t a β€œhacky” way like

_,c1= st.columns([5,1])

this can create weird displays, cause is not a right align. I want proper right alignment
Something like

st.button(..., align='right')


There isn’t a way to do it within the parameters of st.button or configuration of the app. You can inject CSS to change some things, but it will definitely be hacky.

Probably the cleanest thing will be to use the stylable container from the streamlit-extras package. You can use the stylable container around your button and include right-alignment in the CSS.

Has anyone solved this yet.

I tried this:

with stylable_container(
        display: flex;
        justify-content: flex-end;
        width: 100%;
    st.button("Upload Data")

but I get something like this

The issue with st.columns is that buttons and markdowns get indented to a newline if too large. It would be nice if you could autofit the right column.