st.container
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 the "with" notation (preferred) or just call methods directly on the returned object. See examples below.
| Function signature[source] | |
|---|---|
st.container(*, height=None, border=None) | |
| Parameters | |
height (int or None) | Desired height of the container expressed in pixels. If None (default) the container grows to fit its content. If a fixed height, scrolling is enabled for large content and a grey border is shown around the container to visually separate its scroll surface from the rest of the app. Note Use containers with scroll sparingly. If you do, try to keep the height small (below 500 pixels). Otherwise, the scroll surface of the container might cover the majority of the screen on mobile devices, which makes it hard to scroll the rest of the app. |
border (bool or None) | Whether to show a border around the container. If None (default), a border is shown if the container is set to a fixed height and not shown otherwise. |
Examples
Inserting elements using "with" notation:
PythonInserting elements out of order:
PythonUsing height to make a grid:
PythonUsing height to create a scrolling container for long content:
Python
Still have questions?
Our forums are full of helpful information and Streamlit experts.
