Layouts and Containers

Streamlit provides several options for controlling how different elements are laid out on the screen.

screenshot

Display items in a sidebar.

st.sidebar.write("This lives in the sidebar")
st.sidebar.button("Click me!")
screenshot

Columns

Insert containers laid out as side-by-side columns.

col1, col2 = st.columns(2)
col1.write("this is column 1")
col2.write("this is column 2")
screenshot

Expander

Insert a multi-element container that can be expanded/collapsed.

with st.expander("Open to see more"):
  st.write("This is more content")
screenshot

Container

Insert a multi-element container.

c = st.container()
st.write("This will show last")
c.write("This will show first")
c.write("This will show second")
screenshot

Empty

Insert a single-element container.

c = st.empty()
st.write("This will show last")
c.write("This will be replaced")
c.write("This will show first")

Was this page helpful?

editSuggest edits
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.