0.5.0 • Published 6 years ago

react-opium-select v0.5.0

Weekly downloads
14
License
MIT
Repository
github
Last release
6 years ago

react-opium-select

Simple select dropdown with a better UI.

Live demo

Installation

npm i react-opium-select

Usage

Basic example

import React, { Component } from 'react';
import Select from 'react-opium-select';
import 'react-opium-select/style.css';

class App extends Component {
  handleChange(value) {
    console.log(`Selected value: ${value}`);
  }

  render() {
    const options = [
      { label: 'Amritsar', value: 'amritsar' },
      { label: 'Bathinda', value: 'bathinda' },
      { label: 'Chandigarh', value: 'chandigarh' },
      { label: 'Ludhiana', value: 'ludhiana' },
      { label: 'Jalandhar', value: 'jalandhar' }
    ];

    return (
      <div style={{ margin: '200px auto', maxWidth: '200px' }}>

        <Select
          options={options}
          onChange={this.handleChange} />

      </div>
    );
  }
}

export default App;

Configuration

PropsTypeDefault valueDescription
optionsArray-Select options passed as an array of objects. e.g. [{ label: 'Chandigarh', value: 'chandigarh' }, ...]
selectedValueStringnullSelected option
settingsArray-UI settings - style, placeholder, maxItems, animateOnSelect, forceDirection
onChangeFunctionundefinedonChange handler

Settings

PropsTypeDefault valueDescription
styleArray-CSS styling options - padding, background, textColor, radius, borderWidth, borderColor
placeholderString-Placeholder for select dropdown
maxItemsNumbernullScroll items after this number
animateOnSelectBooleantrueSubtle animation on item select
forceDirectionStringnullForce open to a specified direction - up or down

Style

PropsTypeDefault valueDescription
paddingString10px 15pxCSS padding
backgroundString#f1f2f3Background color - solid or gradient.
textColorString#3A3A3DText color, also used to compute scrollbar and hover colors, must be hex code.
radiusNumber0Border radius
borderWidth#Number0Thikness of border
borderColor#String#5D5E5FBorder color

# Applying border is currently an experimental feature.

0.5.0

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.0.1

6 years ago