Dependent multiselect widgets

Hello All,

Great work on Streamlit, guys. Thanks!
I have a question, which really gave me a headache; however, it might (and hope) be simpler than it seems. So, I want to have a dashboard with 4 dropdown lists and the dropdown values should be dependent on the value that the user selects on the other dropdown lists. Think of the following example: If I have a dropdown list of countries and another of cities… If I select “the Netherlands” in the first dropdown list, I would only like to see cities of the Netherlands in the second dropdown list. I would also like to do it the other way around. I would like to be able to choose “Amsterdam” in the second dropdown list and then when I go to the first dropdown list I should only see “the Netherlands” (I should not be able to pick any other country if I have chosen “Amsterdam” in the second one.)

When this is with 2 dropdown lists, it could be possible to write an extensive code with lots of “if” but when I have 4 dropdown lists this way would be give a super long code :confused:

I hope my explanation is clear and I will be really happy to hear that I can do that with Streamlit because I want to keep using it since it is super handy :smiley:

Thank you in advance!

Hi @Angeliki_Kouka, welcome to the Streamlit community!

I think it’s straightforward to make a cascading dependent set of dropdowns using a dictionary (I’d have to try it, just have a mental picture of it), but having them be recursive (any menu making any other menu change) would be pretty difficult I think.

Maybe someone else has an idea…


Hello @randyzwitch ,

Thanks a lot for your prompt response! For the moment, I keep them as cascading dropdowns. If someone else has an idea, I would be happy to hear. Have a good day!

Best Regards,

1 Like