Insert containers laid out as side-by-side columns.
Inserts a number of multi-element containers laid out side-by-side and returns a list of container objects.
To add elements to the returned containers, you can use "with" notation (preferred) or just call methods directly on the returned object. See examples below.
Columns can only be placed inside other columns up to one level of nesting.
Columns cannot be placed inside other columns in the sidebar. This is only possible in the main area of the app.
st.columns(spec, *, gap="small")
spec (int or Iterable of numbers)
Controls the number and width of columns to insert. Can be one of:
gap ("small", "medium", or "large")
The size of the gap between the columns. Defaults to "small".
(list of containers)
A list of container objects.
You can use with notation to insert any element into a column:import streamlit as st col1, col2, col3 = st.columns(3) with col1: st.header("A cat") st.image("https://static.streamlit.io/examples/cat.jpg") with col2: st.header("A dog") st.image("https://static.streamlit.io/examples/dog.jpg") with col3: st.header("An owl") st.image("https://static.streamlit.io/examples/owl.jpg")
Or you can just call methods directly in the returned objects:import streamlit as st import numpy as np col1, col2 = st.columns([3, 1]) data = np.random.randn(10, 1) col1.subheader("A wide column with a chart") col1.line_chart(data) col2.subheader("A narrow column with the data") col2.write(data)
Still have questions?
Our forums are full of helpful information and Streamlit experts.