Length of List affects selectbox behaviour?

Dear Community,

It seems that selectbox doesn’t behave properly if the list is more than 136 items long? i.e. list of countries in the world ( st.sidebar.selectbox(’’,countries) )? Anybody experienced a similar problem? So if the list is that long, selectbox will always select first element in your list regardless of your choice? And I wonder if there is an alternative to have such longlist other than selectbox


Hi @eelyan, welcome to the forum :wave:

It seems to work ok for me. Do you see the same behavior with the script below?

import streamlit as st

options = list(range(150))
i1 = st.sidebar.selectbox("selectbox 1", options, 1)
st.write("value 1:", i1)

Could you share debug info?

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Thank you so much for your prompt reply, I use Python 3.7.4 , no virtual env and the OS is Mac. Your code works perfectly, however, when using my list instead, it didn’t work , top_conf is a list of 185 country names

options = top_conf
i1 = st.sidebar.selectbox("Select Country", options, 3)
st.write("You Selected:", i1)

Could you provide sample code, including data, that we can copy/paste and run to reproduce your issue?

Dear Jonathan

Thanks for your help, it turns out that the problem in another function in my code that caused the problem. It was long night on a silly error, thanks much appreciated.