Skip to content

👽  Add Vertical Space

Submitted by Tyler Richards

Summary

Add n lines of vertical space to your Streamlit app in one command

Functions

add_vertical_space

Add vertical space to your Streamlit app.

Parameters:

Name Type Description Default
num_lines int

Height of the vertical space (given in number of lines). Defaults to 1.

1
Source code in src/streamlit_extras/add_vertical_space/__init__.py
@extra
def add_vertical_space(num_lines: int = 1) -> None:
    """
    Add vertical space to your Streamlit app.

    Args:
        num_lines (int, optional): Height of the vertical space (given in number of lines). Defaults to 1.
    """
    for _ in range(num_lines):
        st.write("")  # This is just a way to do a line break!

Import:

from streamlit_extras.add_vertical_space import add_vertical_space # (1)!
  1. You should add this to the top of your .py file 🛠

Examples

example

def example():
    add_n_lines = st.slider("Add n vertical lines below this", 1, 20, 5)
    add_vertical_space(add_n_lines)
    st.write("Here is text after the nth line!")
Output (beta)