Change selectbox parameters after creation


I’m trying to change the visibility of a selectbox created in the sidebar, based on the tab I have chosen in the main page.

How can I accomplish this?

Hi there,

Thanks for sharing your question with the community! Check out our guidelines on how to post an effective question here – in particular, please share what you’ve tried to implement this so far so we can make suggestions.

Hi @vishhvak, are you looking for something like this?

import streamlit as st

st.sidebar.write("Static sidebar text")
show_hide = st.checkbox("Show sidebar selectbox")

if show_hide:
    st.sidebar.selectbox("My SelectBox", ('A', 'B', 'C'))

I have used a checkbox instead of a tab; you can repurpose the code as required.