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

Deprecated

This function is deprecated. Use st.space(height) instead.

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.

    !!! warning "Deprecated"
        This function is deprecated. Use
        [`st.space(height)`](https://docs.streamlit.io/develop/api-reference/layout/st.space)
        instead.
    """
    show_deprecation_warning(
        "add_vertical_space is deprecated. Use `st.space(height)` instead. "
        "See https://docs.streamlit.io/develop/api-reference/layout/st.space",
        show_once=True,
    )
    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() -> None:
    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)