Mike K
Mike K

Reputation: 6491

Is it possible to get rid of the input field with react-select?

I'm using this package with React, and Im trying to use it as a "result dropdown" for a search. The problem is that I can't seem to get rid of the input field. There is a prop called isSearchable, however all it does is disable the input, it doesn't hide it. My fall back is to either fork it or use another package, but I would really like to get this one working.

I'm currently using it as,

const options = [
  { value: "chocolate", label: "Chocolate" },
  { value: "strawberry", label: "Strawberry" },
  { value: "vanilla", label: "Vanilla" }
];

<Select
  hideSelectedOptions
  menuIsOpen={true}
  isSearchable={false}
  options={options}
>

But this just renders: img

Is it possible to get rid of the input, where it says "Select..."? There's also very little difference with the isDisabled prop, it seems a bit redundant.

Upvotes: 1

Views: 122

Answers (1)

Mike K
Mike K

Reputation: 6491

Figured it out.

<Select
  components={{
    Control: () => null
  }}
  options={options}
/>

Upvotes: 3

Related Questions