Blank line for spacing that actually works?

Numerous posts suggest st.write(‘’), st.write(" "), st.write(‘\n\n’), and similar, with st.write() replace by st.markdown() or st.text(). I even found the PyPi package streamlit-space. All fail to insert a blank line to align a slider control:

from streamlit_space import space 

with st.container(border=True):
    col1, col2 = st.columns((67, 33))
    with col1:
        # Place spacing code here: st.write(), space(), etc.
        slider = st.slider()

The spacing code has no effect. The control remains at the top of the container.

For what it is worth, st.write(‘blah’) inserts the line of text and properly aligns the slider. Of course, there is now text where I don’t want any.

How about using the vertical_alignment argument in st.columns?

st.container has a height parameter so can use st.container(height=300) or similar to insert an empty spacing block.

Use st.write(" ") instead. For less height, I use st.caption(" ")

Thank you so much!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.