0.0.7 • Published 2 years ago

react-native-cross-select v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-cross-select

Select component for react native

Features

  • Using Portal
  • Multiple and Single Select
  • Searchable Select
  • Fully Modifiable

Installation

With NPM

npm install react-native-cross-select

With YARN

yarn add react-native-cross-select

Usage

  • Add provider to main app file
import { SelectProvider } from 'react-native-cross-select';

const Index = () => (
  <SelectProvider>
    <App />
  </SelectProvider>
);

Components

  • Single Select
import Select, { ISelect } from 'react-native-cross-select';

const DATA = [
    {
        label:"Input 1",
        value:1
    },
    {
        label:"Input 2",
        value:2
    }
]

const App = () => {
    const handleChange:ISelect.Select.SelectOnSelectProp = (data) => {
        console.log('Data: ', data);
    };
    
    return(
        <Select data={DATA} onSelect={handleChange} />
    )
};

  • Multiple Select
import { ISelect, MultipleSelect } from 'react-native-cross-select';

const DATA = [
    {
        label:"Input 1",
        value:1
    },
    {
        label:"Input 2",
        value:2
    }
]

const App = () => {
    const handleMultipleChange:ISelect.Select.MultipleSelectOnSelectProp = (data) => {
        console.log('Datas: ', data);
    };
    
    return(
        <MultipleSelect data={DATA} onSelect={handleMultipleChange} />
    )
};

  • Single Select With Search
import Select, { ISelect } from 'react-native-cross-select';

const DATA = [
    {
        label:"Input 1",
        value:1
    },
    {
        label:"Input 2",
        value:2
    }
]

const App = () => {
    const handleChange:ISelect.Select.SelectOnSelectProp = (data) => {
        console.log('Data: ', data);
    };
    
    return(
        <Select data={DATA} onSelect={handleChange} searchable />
    )
};

  • Multiple Select With Search
import { ISelect, MultipleSelect } from 'react-native-cross-select';

const DATA = [
    {
        label:"Input 1",
        value:1
    },
    {
        label:"Input 2",
        value:2
    }
]

const App = () => {
    const handleMultipleChange:ISelect.Select.MultipleSelectOnSelectProp = (data) => {
        console.log('Datas: ', data);
    };
    
    return(
        <MultipleSelect data={DATA} onSelect={handleMultipleChange} searchable />
    )
};

Props

NameDescriptionTypeDefaultRequired
dataData array{label:string; value:stringnumber}[] (Array of data object)[]true
placeholderPlaceholder for select boxstringPlease select... (if searchable true then it's "Search here...")false
widthwidth of select boxnumber250false
heightheight of select boxnumber40false
boxClosedBorderColorBox border color while it's close statestring-false
boxOpenedBorderColorBox border color while it's open statestring-false
closeOnSelectClose on select (it's only for single select)booleantruefalse
onSelectCallback function to handle changefunction-true
placeHolderTextStyleCustom text style for placeholderRN style object{}false
textStyleCustom text styleRN style object{}false
arrowColorOnSelectedArrow color while select box open statestring-false
arrowColorArrow color while select box close statestring-false
backgroundColorBackground color of boxstring-false
searchableSearchable supportboolean-false
listItemTextStyleCustom text style for list itemRN style object{}false
listBoxBackgroundColorList box background colorstring-false
maxListHeightMax list heightnumber-false
listItemSelectedTextStyleCustom text style for list item while selected stateRN style object{}false
listItemSelectedBackgroundColorCustom style for list item while selected stateRN style object{}false
notFoundTextStyleNot found text styleRN style object{}false
noDataTextNo data textstringNo data foundfalse
defaultValueDefault value For single selectstring-false
defaultValuesDefault values For multiple selectarray-false

Thanks for


License

MIT

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago