Set AutoCompleteInput to suggest list of words

31 Views Asked by At

In my Vue project I found that setting the id to "autocompleteInput" made it suggest prevously typed words then the input field is focused:

                <input
                  id="autocompleteInput"
                />

But how do I make it suggest a list of words by default? E.g. how to give the autocompleteInput a list like this: ["Germany", "France", "Spain"] and then it suggests those?

I dont know why setting input id to "autocompleteInput" gives previously typed suggestions but it does.

1

There are 1 best solutions below

0
Rasmus On BEST ANSWER

Solved: Found this simple solution:

              <input
                  list="browsers"
                />
                <datalist id="browsers">
                  <option value="Chrome"></option>
                  <option value="Firefox"></option>
                </datalist>