Insert a multi-element container.
Inserts an invisible container into your app that can be used to hold multiple elements. This allows you to, for example, insert multiple elements into your app out of order.
To add elements to the returned container, you can use "with" notation (preferred) or just call methods directly on the returned object. See examples below.
Function signature[source] | |
---|---|
st.container(*, border=None) | |
Parameters | |
border (bool or None) | Whether to show a border around the container. |
Examples
Inserting elements using "with" notation:
import streamlit as st with st.container(): st.write("This is inside the container") # You can call any Streamlit command, including custom components: st.bar_chart(np.random.randn(50, 3)) st.write("This is outside the container")Inserting elements out of order:
import streamlit as st container = st.container(border=True) container.write("This is inside the container") st.write("This is outside the container") # Now insert some more in the container container.write("This is inside too")
Still have questions?
Our forums are full of helpful information and Streamlit experts.