Autocomplete Option for st.text_input()

Is there any way to have the text_input autocomplete from a column of strings in a DataFrame?

Hey @chefnewman!

For the text_input there currently isn’t a way to have it auto complete.

BUT if you’re looking to select a string from a column of strings in a DataFrame, where they can only use those specific strings, maybe select box or multi select will work for you? They allow you to populate a list of preselected options, and when you type into the field, they show options matching what you have typed so far. They also allow a dropdown box for people to look through all available options.

Here is when you start typing in the field:

Both of these widgets have this behaviour, the select box simply allows only one choice and multi select allows multiple selections!

Happy Streamlit-ing!
Marisa

3 Likes

Works for me also. And just to add a useful note, st.multiselect is good for this since it also allows for blank selection (len(selector)==0) so that user can type in initial selection, or add additional ones.

1 Like

Hey @paulpax,

Do you happen to have a MWE for this?

Hi Marisa,
Can you get the default “Choose an option” to look different from the actual options?

I create a list like so [“Type Here” , option1,option2…optionn] but the “Type Here” looks a lot like the option choices, I’d like the default option to look different (italics and a little more transparent?)

Hey,

Unfortunately, that’s not possible right now. There is likely a way around this by using CSS, I would check around the forum for other posts and see if there is some sample code you can pull from!

Hello, do you have any solution about the this question? I look for the same feature

2 Likes