How to add extra lines space?

Hi,

I have 2 buttons which are close to each other i.e. one button on top and one button below it. Is there a way to add extra line space in between the 2 buttons ?

Thanks

1 Like

Hey @demoacct - you can use st.text with an empty string to insert extra line space:

import streamlit as st

st.button("button 1")
st.text("")
st.button("button 2")
2 Likes

@demoacct Hi mate, you could use the following command below. He will create a line, maybe given to you air of separation. This command it’s (i’m not sure) the same as when you use at jupyter notebook, github markdown. :sunglasses:

import streamlit as st

st.button("First button")
st.markdown("***")
st.button("Second button")
1 Like

Hii!

Can anyone tell…I want to bring my heading in centre…so I need to ad some spaces before that…
How can I do that??

Hi @Akash743! Firstly, welcome to the Streamlit community!! :tada: :partying_face: :tada:

I realize that both st.title and st.header don’t center the text by default. Are you seeing them a bit to the left of the screen as well?

To position them in the middle of your page, you could use st.beta_columns to create three columns and display the title/header in the middle column. To leave enough room for medium-to-long headings, you can size the middle column to be twice as wide as the left and right columns. Below, I’ll compare the before and after versions:

Before:

import streamlit as st
st.title("This is my heading")

After:

import streamlit as st

_, col2, _ = st.beta_columns([1, 2, 1])

with col2:
    st.title("This is my heading") # you can use st.header() instead, too

Is this what you were looking for? :thinking:

Happy Streamlit-ing! :balloon:
Snehan

4 Likes

Thanks you very much :slight_smile:

1 Like