Siddharth Nobell
Siddharth Nobell

Reputation: 138

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

Upvotes: 4

Views: 9809

Answers (3)

Baraa Zaid
Baraa Zaid

Reputation: 424

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

Upvotes: 4

Rafael Colombo
Rafael Colombo

Reputation: 435

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.

Upvotes: 1

Siddharth Nobell
Siddharth Nobell

Reputation: 138

this is already there in selectbox in streamlit.
https://docs.streamlit.io/library/api-reference/widgets/st.selectbox

Upvotes: 0

Related Questions