Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streamlit Autocomplete from list of values

I want to provide suggestions / autocomplete based on a list of values in text_input in streamlit

text_input(label = "select location", max_chars=200, placeholder=" 
<enter_country_name>", autocomplete = [some list of value])

However, I get that the error can be only accepted b or string then how can we suggest something as below

e.g. if write Del -> Delhi similarly, if write Kol -> Kolkata

like image 232
Siddharth Nobell Avatar asked Aug 31 '25 11:08

Siddharth Nobell


2 Answers

Refer to this custom made tool that enables autocomplete from searches, not select boxes: https://github.com/m-wrzr/streamlit-searchbox

like image 82
Baraa Zaid Avatar answered Sep 03 '25 00:09

Baraa Zaid


You can't achieve this with st.text_input. Right now the only way is using st.selectbox ou st.multiselect.

Using st.selectbox you'll have to pass a sequence of options. The user will be able to select one of them OR type a keyword in the selectbox. Along the typing all the options that matches what user is typing will be shown.

enter image description here

Same goes for st.multiselect.

like image 25
Rafael Colombo Avatar answered Sep 02 '25 23:09

Rafael Colombo