Beta Expander on Sidebar

All,
Is it possible to use beta_expander in sidebar ? As I understand it, someone asked a similar question here(Hide/collapse/fold a section) and then that resulted in this contribution ([horiz-layout] Add collapsible_container by karriebear · Pull Request #1978 · streamlit/streamlit · GitHub). Looks like this contribution became the beta_expander. Can someone provide an example if this is possible?

Thanks
Uday

you can use

file_expander = st.sidebar.beta_expander(‘Expander Title’)

Best,

1 Like

@tajmahal,
Thank you for your response. While this adds a beta_expander, could you kindly show, how I would be able to add an input in the beta expander ? Here is what I tried:

# Import required libraries
import streamlit as st
import pandas as pd

# Start setup of the app
# Title
st.subheader("Streamlit Testing")
with st.sidebar.beta_expander('Will it collapse?'):
    # Add user input widgets to the side bar
    param_1 = st.sidebar.number_input(label='Random Value - 1', min_value=-90., max_value=90.)
    param_2 = st.sidebar.number_input(label='Random Value - 2', min_value=-180., max_value=180.)

I would like the inputs to be within the beta_expander, so I can collapse that section.

1 Like

@UGuntupalli
I do not have time to test it out but my hunch says this does not work because you are putting the sidebars again in the sidebar so to speak.

Try removing the .sidebar in the st cals within the sidebar like this:
param_x = st.number_input()

3 Likes