Giter Club home page Giter Club logo

react-native-search-bar's Introduction

React Native Search Bar

The high-quality native search bar for react native.

npm version npm downloads code style: prettier


Getting Started

This is a native library. It does not work with expo or create-react-native-app.

Installation

# npm
npm install react-native-search-bar --save

# yarn
yarn add react-native-search-bar

Pods

If using CocoaPods or React Native version >= 0.60.0

cd ios && pod install && cd ..

Linking

For React Native <= 0.59 only

react-native link react-native-search-bar

If linking fails, follow the manual linking steps

Usage

import SearchBar from 'react-native-search-bar';
<SearchBar
  ref="searchBar"
  placeholder="Search"
  onChangeText={...}
  onSearchButtonPress={...}
  onCancelButtonPress={...}
/>

Managing the keyboard

  • Show - this.refs.searchBar.focus();
  • Hide
    • this.refs.searchBar.blur(); - uses the iOS endEditing:true method on the underlying UISearchBar view.
    • this.refs.searchBar.unFocus(); - calls resignFirstResponder on the UITextField used by the UISearchBar.

Examples

  • Show the keyboard when the view loads:
componentDidMount() {
  this.refs.searchBar.focus();
}
  • Hide the keyboard when the user searches:
...
onSearchButtonPress={this.refs.searchBar.unFocus}
...

For a full list of props check out the typescript definitions file.

There is also an example project in the example directory.

Contribution

For now, only some of the features of UISearchBar are implemented.

Feel free to send a pull request to the next branch. To get started, you can read the "Native UI Components (iOS)" guide on the React Native website.

Along with code contribution, you are welcomed to answer questions asked in the Issues.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.