A React Native component that provides a filterable select dropdown/picker.
npm install react-native-actions-sheet-pickerA React Native component that provides a filterable select dropdown/picker.
width="%33"
height="600"
src="https://github.com/Bur0/react-native-actions-sheet-picker/blob/master/gifs/ios-default.gif"
/>width="%33"
height="600"
src="https://github.com/Bur0/react-native-actions-sheet-picker/blob/master/gifs/ios-filterable.gif"
/>
``sh`
yarn add react-native-actions-sheet-picker
or
`sh`
npm install react-native-actions-sheet-picker
`jsx
import React, { useState, useMemo, useEffect } from 'react';
import { StyleSheet, Text, TouchableOpacity, SafeAreaView } from 'react-native';
import { Picker, onOpen } from 'react-native-actions-sheet-picker';
/*
**Example data:
*/
import countries from './countries.json';
export default function App() {
const [data, setData] = useState([]);
const [selected, setSelected] = useState(undefined);
const [query, setQuery] = useState('');
useEffect(() => {
setData(countries);
}, []);
/*
**Example filter function
* @param {string} filter
*/
const filteredData = useMemo(() => {
if (data && data.length > 0) {
return data.filter((item) =>
item.name
.toLocaleLowerCase('en')
.includes(query.toLocaleLowerCase('en'))
);
}
}, [data, query]);
/*
**Input search
*@param {string} text
*/
const onSearch = (text) => {
setQuery(text);
};
return (
onPress={() => {
onOpen('country');
}}
>
data={filteredData}
inputValue={query}
searchable={true}
label="Select Country"
setSelected={setSelected}
onSearch={onSearch}
/>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
},
button: {
backgroundColor: '#8B93A5',
padding: 10,
borderRadius: 6,
marginTop: 50,
},
});
`
| Properties | Type | Description | Default |
| ------------------------ | ---------- | ------------------------------------- | --------------------------------------- |
| id
\*_required_ | string | A unique id for the ActionSheet | |array
| data | | Array of list items | [] |string
| inputValue | | The value to show for the text input. | |boolean
| searchable | | Searchable state | false |boolean
| loading | | Loading state | false |string
| label | | Flatlist label | |string
| height | | ActionSheet height | Dimensions.get('window').height * 0.5 |string
| closeText | | Close text | "Close" |string
| placeholderText | | Placeholder text | "Search" |string
| noDataFoundText | | No data found text | "No Data Found." |string
| placeholderTextColor | | Placeholder text color | #8B93A5 |function
| setSelected | | Selected function | |function
| onSearch | | Textinput search function | |function
| renderListItem | | Render List item | |
| Properties | Type | Description |
| ------------------------ | ---------- | ------------------------------------- |
| onOpen | function | SheetManager show |function
| onClose | | SheetManager hide |
| Properties | Type | Description |
| -------------------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| actionsSheetProps | object | react-native-actions-sheet | |object
| flatListProps | | FlatListProps | |object` | TextInputProps | |
| searchInputProps |
* [ ] Multiple select
* [x] renderListItem | props
* [x] Selected highlight
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT