How do I add a Component to the sidebar?

You can add a component to st.sidebar using the with syntax. For example:

with st.sidebar:
    my_component(greeting="hello")

In fact, you can add your component to any layout container (eg st.columns, st.expander), using the with syntax!

col1, col2 = st.columns(2)
with col2:
    my_component(greeting="hello")

Was this page helpful?

forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.