Insert containers separated into tabs.
Inserts a number of multi-element containers as tabs. Tabs are a navigational element that allows users to easily move between groups of related content.
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.
Warning
All the content of every tab is always sent to and rendered on the frontend. Conditional rendering is currently not supported.
Function signature | |
---|---|
st.tabs(tabs) | |
Parameters | |
tabs (list of strings) | Creates a tab for each string in the list. The string is used as the name of the tab. The first tab is selected by default. |
Returns | |
(list of containers) | A list of container objects. |
Examples
You can use with notation to insert any element into a tab:
tab1, tab2, tab3 = st.tabs(["Cat", "Dog", "Owl"]) with tab1: st.header("A cat") st.image("https://static.streamlit.io/examples/cat.jpg", width=200) with tab2: st.header("A dog") st.image("https://static.streamlit.io/examples/dog.jpg", width=200) with tab3: st.header("An owl") st.image("https://static.streamlit.io/examples/owl.jpg", width=200)(view standalone Streamlit app)Or you can just call methods directly in the returned objects:
tab1, tab2 = st.tabs(["📈 Chart", "🗃 Data"]) data = np.random.randn(10, 1) tab1.subheader("A tab with a chart") tab1.line_chart(data) tab2.subheader("A tab with the data") tab2.write(data)(view standalone Streamlit app)