Adding Streamlit Component to div tags

Is there a way for me to put streamlit components into an HTML div tag. Something along this line:

st.markdown('<div class="my-box">', unsafe_allow_html=True)
st.plotly_chart(fig)
st.markdown('</div>', unsafe_allow_html=True)

Right now when I try to do this it just creates a box and my graph below it. My goal is to try to put the graph inside a created box.

If you pass a key to st.container

with st.container(key="my-box"):
    st.plotly_chart(fig)

… you will get a div with class st-key-my-box.

1 Like