Layouts and Containers
Complex layouts
Streamlit provides several options for controlling how different elements are laid out on the screen.

Columns
Insert containers laid out as side-by-side columns.
Python
col1, col2 = st.columns(2)
col1.write("this is column 1")
col2.write("this is column 2")

Container
Insert a multi-element container.
Python
c = st.container()
st.write("This will show last")
c.write("This will show first")
c.write("This will show second")

Modal dialog
Insert a modal dialog that can rerun independently from the rest of the script.
Python
@st.dialog("Sign up")
def email_form():
name = st.text_input("Name")
email = st.text_input("Email", type="email")

Empty
Insert a single-element container.
Python
c = st.empty()
st.write("This will show last")
c.write("This will be replaced")
c.write("This will show first")

Expander
Insert a multi-element container that can be expanded/collapsed.
Python
with st.expander("Open to see more"):
st.write("This is more content")
Popover
Insert a multi-element popover container that can be opened/closed.
Python
with st.popover("Settings"):
st.checkbox("Show completed")

Sidebar
Display items in a sidebar.
Python
st.sidebar.write("This lives in the sidebar")
st.sidebar.button("Click me!")

Bottom
Display items at the bottom of the window.
Python
st.bottom.chat_input("Say something")

Space
Add vertical or horizontal space.
Python
st.space("small")

Tabs
Insert containers separated into tabs.
Python
tab1, tab2 = st.tabs(["Tab 1", "Tab2"])
tab1.write("this is tab 1")
tab2.write("this is tab 2")
Still have questions?
Our forums are full of helpful information and Streamlit experts.