Hey @Hanan_Shteingart ,
Apologies I missed your query here.
Ofcourse, an UI can be designed without specifically the st.container()
widget, if the workarounds are known.
However, there are times, when the container widget comes very handy , for instances (Here’s the reference to the doc),
import streamlit as st
import numpy as np
st.header("Demo")
cont = st.container()
_plotType = st.selectbox("Plot Type", ['Line','Bar'])
if _plotType == 'Line':
cont.header("Line Plot")
cont.line_chart(np.random.randn(50, 3),use_container_width = True)
if _plotType == 'Bar':
cont.header("Bar Plot")
cont.bar_chart(np.random.randn(50, 3),use_container_width = True)
Probably you are already aware, that the Streamlit App, runs line by line in your code. In this case, let’s consider, you plan to plot in the very top of your app, just below the header. So, you leave a empty container, and populate it based on your user’s choice. If container layout isn’t used, the plot appears after the user’s choice .
I hope this makes sense. (Perhaps a better example would make more sense , let me know) .
Best
Avra