1.0.5 • Published 5 years ago

@joenied/select2 v1.0.5

Weekly downloads
1
License
-
Repository
github
Last release
5 years ago

React Select2 Component

Demo

https://codesandbox.io/s/new-ruyxe

Installation

npm install @joenied/select2 --save

How To Use

First import this component where you want to use it

import { Select2 } from "@joenied/select2"; import "@joenied/select2/dist/select.css";

Then just render it

    <Select2 
        selected={e => doThingsWithValue(e)} 
        options={[ 
            { label: "one", value: "one" },
            { label: "two", value: "two" }
        ]}
    />

Props

PropDescriptionDefault value
optionsan array of objects with label and value propertiesempty array
multiSelectAllow selecting of multiple optionsfalse
selectedGet the value and do stuff with itnull

Example

import React, { Component } from "react";
import { Select2 } from "@joenied/select2";
import "@joenied/select2/dist/select.css";

class App extends Component {
  render() {
    return (
        <Select2
          selected={e => doThingsWithValue(e)}
          options={[
            { label: "one", value: "one", optgroup: "numbers" },
            { label: "two", value: "two", optgroup: "numbers" },
            { label: "three", value: "three", optgroup: "numbers" },
            { label: "A", value: "A", optgroup: "letters" },
            { label: "B", value: "B", optgroup: "letters" },
            { label: "C", value: "C", optgroup: "letters" }
          ]}
        />
    );
  }
}

export default App;
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago