npm install rn-searchboxA simple Search Bar with Flatlist Component for handling huge and large data.
With simple search capability which can be utilised by handing the component data to Flatlist Component and providing a onClick function which will receive the item selected of the data array.
The search function uses a Dice Algorithm to traverse the data and looks for an indexOf the user input within all strings, numbers, and boolean values in the data.
Build for React Native App and works on both Android and iOS.

``
npm install --save rn-searchbox
or
yarn add rn-searchbox
`
Property | Type | Default | Description |
:---------|:--------|:----------|:------------|
onClick(item) | function | null | Fires after each Click and return item data.[]
itemsStyles | array | | The array of styles of data to be displayed in FlatList.[]
data | array | required* | The array of data to be searchedSearch
placeholder | string | | The placeholder for the search bar.null
onFocus | function | | Fires when the search bar receives focus.null
onBlur | function | | Fires when the search bar loses focus.Clear search text
closeButton | Component | MaterialIcon | Sets the close button component.
closeButtonAccessibilityLabel | string | | Accessibility label for the close button.0
heightAdjust | number | | Adjust the height of the search bar.white
backgroundColor | string | | The background colour of the search bar.gray
iconColor | string | | The color of the back and X icons.gray
textColor | string | | The color of the search bar text.lightskyblue
selectionColor | string | | The color of the the search bar cursor and text selection.lightgray
placeholderTextColor | string | | The color of the placeholder text.false
showOnLoad | boolean | | Show the search bar when it is first rendered.false
clearOnShow | boolean | | Clear input when the search bar is shown.true
clearOnHide | boolean | | Clear input when the search bar is hidden.false
clearOnBlur | boolean | | Clear input when the search bar is blurred.true
focusOnLayout | boolean | | Focus the text input box whenever it is shown.true
autoCorrect | boolean | | AutoCorrect the search bar text.sentences
autoCapitalize | string | | Auto capitialize behaviour of the text input - enum('none', 'sentences', 'words', 'characters')System
keyboardAppearance | string | 'default' | Determines the color of the keyboard.
fontFamily | string | | The font family to be used.
fontSize | number | 20 | Sets the font size.
`jsx
import React, { Component } from 'react'
import { StyleSheet, Alert } from 'react-native'
import SearchBox from 'rn-searchbox'
export default class Example extends Component {
onClick(item) {
Alert.alert('Item: '+JSON.stringify(item))
}
render() {
return (
showOnLoad
onClick={(item) => this.onClick(item)}
itemsStyles={itemsStyle()}
/>
)
}
}
const itemsStyle = () => {
return {
name: {
fontSize: 18
},
email: {
color: 'red'
},
phone: {
fontSize: 16,
color: 'blue'
}
}
}
const data = {
"users":
[
{
"key": "0",
"name": "Proxima Midnight",
"phone": "+216 54 548 216"
},
{
"key": "1",
"name": "Ebony Maw",
"email": "ebony@appdividend.com",
},
{
"key": "2",
"name": "Black Dwarf",
},
{
"key": "3",
"name": "Mad Titan",
"email": "thanos@appdividend.com",
"phone": "+216 54 548 100",
"adress": "Sousse, Tunis"
},
{...}
]
}
``
* Possibility to add a custom icon/image to the ListView
* New Algorithm for String Matching
* Update docs for Box component
* Update react, react-native & other dependencies
Feel free to contact me or create an issue.
kerim selmi karimation
This project is licensed under the MIT License