0.4.0 • Published 4 years ago

simple-react-select v0.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

simple-react-select

npm GitHub Build Status Coverage Status

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

PropsDescriptionTypeOptDefault
placeholderchange the text displayed when no option is selectedstring
selectcontrol the current valuestring
noOptionsTextText to display when there are no optionsstring
loadingTextText to display when loadingstring
isLoadingIconneed loading icon or not when loadingbooleantrue
selectCustomStyleselect custom styleobject{ width: '300px', selectColor: stateBgColor0, selectBorderRadius: '0', selectBorderColor: 'black', activeBorderColor: 'red' }{}
optionsCustomStyleoptions custom styleobject{ maxHeight: '200px', optionsBorderColor: 'black', optionsBorderRadius: '0', optionHoverBgColor: '#eee', optionActiveBgColor: 'pink', optionActiveColor: 'blue'}{}
optionsIsLoadingloading controlbooleanfalse
onSelectChangesubscribe to change eventsfunction(res) => {}
isSearchableallow the user to search for matching optionsbooleanfalse
isClearableclear select or input valuebooleanfalse

LICENSE

MIT

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