2.4.0 • Published 5 years ago

react-dynamic-select v2.4.0

Weekly downloads
14
License
Unlicense
Repository
github
Last release
5 years ago

React-Dynamic-Select

React-Select with added functionality to display as radios/checkboxes depending on how many options are provided.

Useful when options are configurable and can be of varying size. It is generally recommended to show all options if there are 5 or fewer, and show a select otherwise.

Installation

Install react-dynamic-select:

yarn add react-dynamic-select

Then:

import DynamicSelect from 'react-dynamic-select'

Basic Usage

import React from 'react'
import DynamicSelect from 'react-dynamic-select'

export default ({ options, selectedValue, onChange }) =>
  <DynamicSelect options={options} value={selectedValue} onChange={onChange} />

Props

PropTypeUsage
cutoffnumberThe cutoff at which to display selects rather than radios/checkboxes. Defaults to 5.
inputPropsObjectProps to pass to the inputs.
itemsArray of ObjectsItems that can be selected in the form of objects with value and label props.
labelPropsObjectProps to pass to the labels.
multipleboolWhether or not this is a multi-select. Dictates whether radios or checkboxes are shown. Defaults to false.
namestringThe name of the input. Needed to group radio buttons.
selectPropsObjectProps to pass to the react-select Select, as seen here. Note that name, options, value, multi and onChange are passed automatically so do not need to be specified again.
valueArray if multiple, otherwise anyThe selected value (or values if in multiple select mode)
onChangefuncFunction to call when value is updated. In multiple select mode, the entire array of values will be passed to onChange.

Styling

No styling is provided by default. You can either add your own or refer to React-Select's style installation guide here, but this will only style the selects themselves, not the radios/checkboxes.

2.4.0

5 years ago

2.3.0

5 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago