New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simple-react-select

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-react-select

react select component

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

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: stateBgColor[0], 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

Keywords

react

FAQs

Package last updated on 16 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts