Coder Social home page Coder Social logo

ananddayalan / react-native-material-design-searchbar Goto Github PK

View Code? Open in Web Editor NEW
51.0 4.0 31.0 34 KB

react native material design searchbar

License: MIT License

JavaScript 100.00%
searchbar react-native react mdl material-design find search searchinput

react-native-material-design-searchbar's Introduction

react-native-material-design-searchbar

A React Native Material Design SearchBar

Setup

Install the SearchBar from npm with npm i -S react-native-material-design-searchbar. Then, require it from your app's JavaScript files with import SearchBar from 'react-native-material-design-searchbar'. This library depends on react-native-vector-icons. Please link it by following their installation guide.

Usage

All props are optional except height.

import React, { Component } from 'react';
import SearchBar from 'react-native-material-design-searchbar';

export default class ExampleComponent extends Component {
  render() {
    return (
      <SearchBar
        onSearchChange={() => console.log('On Search Change')}
        height={50}
        onFocus={() => console.log('On Focus')}
        onBlur={() => console.log('On Blur')}
        placeholder={'Search...'}
        autoCorrect={false}
        padding={5}
        returnKeyType={'search'}
      />
    );
  }
};

Available Props

  • onSearchChange: Callback on search change
  • onClear: Callback when the 'X' button is pressed. This also calls onSearchChange with an empty string.
  • searchValue: Initializes the input field. Changing this prop does not change the input value.
  • onBackPress: Optional function, Callback on back icon pressed
  • alwaysShowBackButton: Optional bool, use if you want to always show the back button instead of search, default is false
  • iconCloseName: Optional string, use it to customize the close icon
  • iconSearchName: Optional string, use it to customize the search icon
  • iconBackName: Optional string, use it to customize the back icon
  • iconCloseComponent: Optional object, custom component for the close icon (overrides iconCloseName)
  • iconSearchComponent: Optional object, custom component for the search icon (overrides iconSearchName)
  • iconBackComponent: Optional object, custom component for the back icon (overrides iconBackName)
  • iconColor: Optional string, use it to define a different padding size, default is #737373
  • placeholder: Optional string, use it to customize the placeholder text, default is eSearch...
  • placeholderColor: Optional string, use it to define a different placeholder color, default is #bdbdbd
  • returnKeyType: Optional string, use it to customize the return key type
  • padding: Optional string, use it to define a different padding size, default is 5
  • inputStyle: Optional string, use it to pass your style to the containing View
  • inputProps: Optional object, use it to pass additional props to the TextInput, for example {autoFocus: true}
  • textStyle: Optional string, use it to pass your style to the TextInput

The React packager will include the SearchBar component in your app's JS package and make it available for your app to use.

Contributing

Contributions are welcome.

LICENSE

MIT

react-native-material-design-searchbar's People

Contributors

ananddayalan avatar aranda-adapptor avatar cvblixen avatar dundalek avatar iroachie avatar johnwoos avatar naoto-ida avatar natsu12 avatar peacechen avatar tyokusuma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-material-design-searchbar's Issues

dismissKeyboard can't be found

I just installed your component but it doesn't work. It throws an error on dismissKeyboard because it can't find it in the package dependencies

Styles should support arrays

React supports passing arrays as the styles prop, even arrays of arrays. inputStyle and textStyle are restricted to object PropTypes, but should also support array types.

Old version published to npm

The new version 1.1.4 published on npm removed the props you had previously. The wrong version was published.

The version now on npm doesn't have onBackPress, or alwaysShowBackButton. There were there on 1.1.2

Contributing

Hey I saw you send me an invite to collaborate. Is everything okay? What's happening with the project?

error with loaders?

hi im new to react, and i cant test the component because it fails here:

node_modules/react-native-material-design-searchbar/SearchBar.js Unexpected token (30:19)
You may need an appropriate loader to handle this file type.

any ideas?

allow pass more props to TextInput

Hi,
i want to pass the prop disableFullscreenUI to the TextInput , currently to do that i have copied the code then i modified what i want it.
i think you can allow pass others props to TextInput component

Close button not clearing search value

On React Native 0.55 (and possibly earlier versions), clicking the close button no longer clears the text.

https://github.com/ananddayalan/react-native-material-design-searchbar/blob/master/SearchBar.js#L85

Using setNativeProps isn't good practice because there are platform differences between Android and iOS that could break it. And now we know that updated versions of React Native have broken it altogether.

The better way is to store the search value in state and pass that as a prop to the TextInput. I'll submit a PR.

How can I set the text from props

I need to keep the state of the search, but when I close the app into the background and then open it again the text in the search bar is gone. This is ok though as I save the query in the state. How can I then reinitialize the text in the search to the state text when opened again.

Is there a prop like setText={} or something?

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.