Skip to content

jestingthomas/multi-select-dropdown-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple multiselect dropdown.

Usage

import React, { Component } from "react";
import "./App.scss";

import MultiSelect from "./MultiSelect";

class App extends Component {
  state = {
    countries: [
      { CountryID: "1", CountryName: "Afghanistan" },
      { CountryID: "2", CountryName: "Albania" },
      { CountryID: "3", CountryName: "Algeria" },
      { CountryID: "4", CountryName: "Andorra" },
      { CountryID: "5", CountryName: "Angola" },
      { CountryID: "6", CountryName: "Antigua and Barbuda" },
      { CountryID: "7", CountryName: "Argentina" },
      { CountryID: "8", CountryName: "Armenia" },
      { CountryID: "9", CountryName: "Australia" },
      { CountryID: "10", CountryName: "Austria" },
      { CountryID: "11", CountryName: "Azerbaijan" },
      { CountryID: "12", CountryName: "Bahamas" }
    ],
    selectedCountries: []
  };

  onCountrySelection = selection => {
    this.setState({ selectedCountries: selection });
  };

  render() {
    return (
      <>
        <div style={{ width: "100%" }}>
          <h1
            style={{ margin: "0px auto", width: "35%", padding: "4rem 0 0 0" }}
          >
            Multi Select Dropdown for ReactJS
          </h1>
        </div>
        <div className="App">
          <MultiSelect
            placeholder="Country"
            itemId="CountryID"
            itemValue="CountryName"
            selected={this.state.selectedCountries}
            onSelectionChange={this.onCountrySelection}
            options={this.state.countries}
          />
        </div>
      </>
    );
  }
}

export default App;

About

This is a simple multi select dropdown for reactjs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published