Installation
You can install the React Select component via npm:
npm i @oshq/react-select
First you need to include React select's css file in your project as below.
import '@oshq/react-select/index.css';
Basic Implementation
import Select from '@oshq/react-select';
import '@oshq/react-select/index.css';
const App = () => {
const [selected, setSelected] = useState(undefined);
const options = [
{ label: 'apple', value: 'apple' },
{ label: 'ball', value: 'ball' },
{ label: 'cat', value: 'cat' },
{ label: 'dog', value: 'dog' },
];
return (
<Select
value={selected}
placeholder="Select item"
onChange={(_,val) => {
setSelected(val);
}}
options={async () => options}
/>
);
};