0.4.0 • Published 4 years ago
simple-react-select v0.4.0
simple-react-select
Home Page
Test will finish soooooooooooooooooooooooooooooooooooooooooooooooooon! ( •̀ᄇ• ́)ﻭ✧
Install
$ yarn add simple-react-select
// or
$ npm install simple-react-select --save
How to use
Usage
Then you need to import its component and css:
import Select from 'simple-react-select'
import 'simple-react-select/lib/simple-react-select.css'
Make sure you have react@16.8.6 installed.
"peerDependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
Example
Now, let's place component in your Web APP!
import React, {memo, useState} from 'react';
import Select from 'simple-react-select';
import 'simple-react-select/lib/simple-react-select.css'
const App = memo(() => {
const optionList = [
{ value: 'Ocean', color: '#00B8D9' },
{ value: 'Blue', color: '#0052CC', isDisabled: true },
{ value: 'Purple', color: '#5243AA' },
{ value: 'Red', color: '#FF5630' },
{ value: 'Orange', color: '#FF8B00' },
{ value: 'Yellow', color: '#FFC400' },
{ value: 'Green', color: '#36B37E' },
{ value: 'Forest', color: '#00875A' },
{ value: 'Slate', color: '#253858' },
{ value: 'Silver', color: '#666666' },
];
const stateSelect = useState('');
const attribute = {
select: stateSelect[0],
onSelectChange: val => stateSelect[1](val),
};
return (
<div>
<Select {...attribute}>
{optionList.map(item => {
return (
<div key={item.value} value={item.value} disabled={item.isDisabled}>
{item.value}
</div>
);
})}
</Select>
</div>
);
});
If you wanna explore more usages, here's a playground on CodeSandBox.io.
Attribute
Props | Description | Type | Opt | Default |
---|---|---|---|---|
placeholder | change the text displayed when no option is selected | string | — | — |
select | control the current value | string | — | — |
noOptionsText | Text to display when there are no options | string | — | — |
loadingText | Text to display when loading | string | — | — |
isLoadingIcon | need loading icon or not when loading | boolean | — | true |
selectCustomStyle | select custom style | object | { width: '300px', selectColor: stateBgColor0, selectBorderRadius: '0', selectBorderColor: 'black', activeBorderColor: 'red' } | {} |
optionsCustomStyle | options custom style | object | { maxHeight: '200px', optionsBorderColor: 'black', optionsBorderRadius: '0', optionHoverBgColor: '#eee', optionActiveBgColor: 'pink', optionActiveColor: 'blue'} | {} |
optionsIsLoading | loading control | boolean | — | false |
onSelectChange | subscribe to change events | function | — | (res) => {} |
isSearchable | allow the user to search for matching options | boolean | — | false |
isClearable | clear select or input value | boolean | — | false |
LICENSE
0.4.0
4 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.2.11
5 years ago
0.2.10
5 years ago
0.2.9
5 years ago
0.2.8
5 years ago
0.2.7
5 years ago
0.2.6
5 years ago
0.2.5
5 years ago
0.2.4
5 years ago
0.2.3
5 years ago
0.2.2
5 years ago
0.2.1
5 years ago
0.2.0
5 years ago
0.1.8
5 years ago
0.1.7
5 years ago
0.1.6
5 years ago
0.1.5
5 years ago
0.1.4
5 years ago
0.1.3
5 years ago
0.1.2
5 years ago
0.1.1
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago