React-select: Customize prompt text when creating a new option in Creatable

Created on 21 Sep 2017  路  4Comments  路  Source: JedWatson/react-select

Hello!
We're using react-select in our project and we need the abilty to customize prompt text (instead of default "Create option"), and I implemented it as prop. I think it would be useful for others.
Here is an example:

<Creatable
  options={some_options}
  multi={false}
  promptText="My custom prompt"
/>

Most helpful comment

To those that come here, the prop name is now formatCreateLabel.

So:

formatCreateLabelCreator => (value) {
  return 'My custom prompt'
}

<Creatable
  ...
  formatCreateLabel={formatCreateLabelCreator}
/>

All 4 comments

It can be done much easier, then I supposed. Sorry, closing issue :)

@alpolishchuk, How can this be done?

@garysed, there is a prop, called promptTextCreator, where you can pass a function, that returns desired prompt text, i.e.

promptTextCreator(value) {
  return 'My custom prompt'
}

<Creatable
  ...
  promptTextCreator={promptTextCreator}
/>

To those that come here, the prop name is now formatCreateLabel.

So:

formatCreateLabelCreator => (value) {
  return 'My custom prompt'
}

<Creatable
  ...
  formatCreateLabel={formatCreateLabelCreator}
/>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

MindRave picture MindRave  路  3Comments

Meesam picture Meesam  路  3Comments

x-yuri picture x-yuri  路  3Comments

joshualimpj picture joshualimpj  路  3Comments

ericj17 picture ericj17  路  3Comments