How to disable input on react-select
? Is that possible? I just want it to be a dropdown.
<Select
placeholder="Action"
className="col-3 mt-3"
value={orderStatusInput}
onChange={this.onOrderStatusChange}
options={orderStatusOptions}
/>
To disable a button when an input is empty with React, we can set the input's value as a state's value. Then we can use the state to conditionally disable the button when the state's value is empty.
We can programmatically clear a React-Select dropdown by resetting the value that is set as the value of the value prop to null . Then the dropdown will be cleared. We have the options array with the value and label properties. value has the selection's value.
To make React Select act as a dropdown
export default function App() {
return (
<div>
<ReactSelect isSearchable={false} />
</div>
);
}
If you want the search input to be disabled and just want it to be a dropdown, you can set the isSearchable
property to false
:
<Select
placeholder="Action"
className="col-3 mt-3"
value={orderStatusInput}
onChange={this.onOrderStatusChange}
options={orderStatusOptions}
isSearchable={false}
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With