Giter Site home page Giter Site logo

react-select-multi's Introduction

React Select Multi

npm version Build Status Coverage Status

Description

A versatile React Component providing awesome UI select components.

  • default = basic select (single option)
  • isMultipleSelect = multiple select (multiple options)
  • isSearchable = select with search input field

State management options

  • React Component state
  • Redux

Installation

With Yarn:

yarn add react-select-multi

With NPM:

npm install react-select-multi

1. Basic Usage (SelectState): uses component state for state management

import React, { Component } from 'react';
import { SelectState } from 'react-select-multi';

class MyComponent extends Component {
  render() {
    return (
      <SelectState
        id="category-select"
        options={options}
        styles={styles}
        onCheck={onCheck}
        selected={selected}
      />
    );
  }
}

2. Basic Usage (SelectConnected): uses Redux for state management

import React, { Component } from 'react';
import { SelectConnected } from 'react-select-multi';

class MyComponent extends Component {
  render() {
    return (
      <SelectConnected
        id="select-multi-1"
        options={options}
        initialSelected={initialSelected}
        styles={styles}
        selected={selected}
      />
    );
  }
}

Configuration

  • R: required
  • ** (styles): see below

Universal Properties

Prop Type Default Description
id string R Unique identifier for the component
isMultipleSelect boolean false Enable multiple options to be selected
isSearchable boolean false Enable search input for options
label string '' Label for component (above MultiSelect)
placeholder string '' Placeholder for control bar
options array R Options for MultiSelect
styles object ** CSS class names for MultiSelect

SelectState Properties

Prop Type Default Description
selected array [] Options that are selected; keep this updated (in combination with onCheck) in order for selected options to be updated
onCheck func R Callback, invoked after an option is clicked, onCheck(option.tag, isMultipleSelect)

SelectConnected Properties

Prop Type Default Description
initialSelected array [] Options to be pre-selected

Styles

Default classNames:

styles: {
  wrapper: 'rsm-wrapper',
  label: 'rsm-label',
  controlContainer: 'rsm-control__container',
  controlPlaceholder: 'rsm-control__placeholder',
  search: 'rsm-search',
  expandIcon: 'rsm-arrow-down',
  collapseIcon: 'rsm-arrow-up',
  optionContainer: 'rsm-option__container',
  optionBar: 'rsm-option__bar',
  optionCheckbox: 'rsm-option__checkbox',
};

Tests

Run flow check

yarn flow

Run test suite

yarn spec

Run with coverage report

yarn coverage

Run linter

yarn lint

Credits

Thanks to Lyn, JD, Mike, Anoop, and ๐ŸŒณ


Licence

Apache-2.0

react-select-multi's People

Contributors

anupvarghese avatar danielmoi avatar dependabot[bot] avatar johndagostino avatar lyntco avatar scoutski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.