Skip to content

Make create option always visible, even when not writing. Any idea on how to implement? #5778

Answered by manjushsh
AndreaEsposit asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @AndreaEsposit , it is possible to achieve this with isValidNewOption props.
You can check it on this code sandbox

If you need 'Create "x" ' all time, even when empty, just pass isValidNewOption={(input) => () => true} which will show up like image attached below.

Sample Code to show Create text once user enters anything in input:

<CreatableSelect
        isClearable
        isValidNewOption={(input) => input?.length}    // For always show:   () => true     For always hide: () => false
        // menuIsOpen
        isDisabled={isLoading}
        isLoading={isLoading}
        onChange={(newValue) => setValue(newValue)}
        onCreateOption={handleCreate}
        value={value}
      …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AndreaEsposit
Comment options

Answer selected by AndreaEsposit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants