Hi,
given a widget, for example st.button, how can i align it to the right?
instead of default left
thanks
Hi,
given a widget, for example st.button, how can i align it to the right?
instead of default left
thanks
Hi,
thanks for the quick answer.
I don’t a “hacky” way like
_,c1= st.columns([5,1])
c1.button(...)
this can create weird displays, cause is not a right align. I want proper right alignment
Something like
st.button(..., align='right')
thanks
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(
key="Upload_Data",
css_styles="""
button{
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.
The solution with streamlit_extras
with stylable_container(
key="Upload_Data",
css_styles="""
button{
float: right;
}
"""
):
submit = st.button("Upload data")
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.