0.1.3 • Published 5 years ago

react-quick-select v0.1.3

Weekly downloads
231
License
MIT
Repository
github
Last release
5 years ago

react-quick-select

Quick select word(s) with an inline like completion

NPM Pretter

Demo at meain.io/react-quick-select

Install

npm install --save react-quick-select

Usage

import * as React from 'react'

import QuickSelect from 'react-quick-select'

class Example extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      option: 0
    };
  }

  onSelect(option, index) {
    this.setState({ option: index });
  }

  render() {
    const options = [
      { value: 1, label: "one" },
      { value: 1, label: "two" },
      { value: 2, label: "three" }
    ];
    return (
      <div style={{ display: "flex" }}>
        You are number
        <QuickSelect
          options={options}
          selected={this.state.option}
          onSelect={this.onSelect.bind(this)}
        />
        .
      </div>
    );
  }
}

For a more complex example check examples

Props

PropDefault
selected0Currently selected element
optionsList of options. An option is a dict with 'value' and 'label' as keys
height'200px'Height of the popup for selection
widthWidth of the popup for selection
renderer(option) => {option.label}A function which takes option and index to return a react element for options in the popup
trigger(option) => {option.label}A function which takes option and index to return a react element for the trigger
onSelectWhat to do on selection. Takes option and index as args

License

MIT © meain