Moon
Moon

Reputation: 149

Add value to props when no matches found with React Bootstrap Typeahead

With React Bootstrap Typeahead, if there is no record found and display "no matches found", is it possible I can add that value to the selected props when I click enter?

enter image description here

Upvotes: 1

Views: 798

Answers (2)

Rejwanul Reja
Rejwanul Reja

Reputation: 1491

Use the props like emptyLabel="YOUR_CUSTOM_TEXT"

Upvotes: 0

ericgio
ericgio

Reputation: 3509

You can use the allowNew prop to add arbitrary items to the selections:

<Typeahead
  allowNew
  options={[...]}
  selected={[...]}
/>

When users enter a string that isn't found in the set of options, they'll be presented with a menu option giving them the ability to add the text they've entered as a selection:

enter image description here

Here's a working example: https://codesandbox.io/s/rbt-custom-selections-18piu

Upvotes: 1

Related Questions