1.0.2 • Published 2 years ago

@ocean28799/react-native-animated-searchbox v1.0.2

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

React Native - Animated Searchbox

A simple search box with animation. Compatible with Expo CLI and React Native CLI.

  • Easy to use,
  • Lightweight, fast, flexible and easy customizable,
  • Support both IOS & Android Devices,
  • Also Support React Native Web

Install

We used a search SVG icon in this project.
So, you need to install the React Native SVG library before continue the installation.

After that;

npm install @ocean28799/react-native-animated-searchbox --save

--- OR ---

yarn add @ocean28799/react-native-animated-searchbox

Demo

|SCREENSHOT|

Usage

import React, { useRef } from "react";
import AnimatedSearchBox from "@ocean28799/react-native-animated-searchbox";
import { View } from "react-native";

export default function Demo() {
  const refSearchBox = useRef();
  //Call for the open
  const openSearchBox = () => refSearchBox.current.open();

  //Call for the close
  const closeSearchBox = () => refSearchBox.current.close();

  return (
    <View style={{ width: "100%" }}>
      <AnimatedSearchBox
        ref={(ref) => (refSearchBox.current = ref)}
        placeholder={"Search"}
        placeholderTextColor="#848484"
        backgroundColor="#f6f6f7"
        searchIconColor="#000"
        focusAfterOpened
        searchIconSize={18}
        borderRadius={12}
        onChangeText={(text) => {
          console.log("Input: ", text);
        }}
        onBlur={() => closeSearchBox()}
      />
    </View>
  );
}

Properties

KeyDescriptionValue TypeIs RequiredDefault
heightHeight of the search boxnumberfalse48
borderRadiusBorder radius of the search boxnumberfalse48
fontSizeFont size of the search boxnumberfalse20
backgroundColorBackground color of the search boxcolor codes (hex,rgb,rgba)falsergba(255,255,255,0.70)
placeholderTextColorPlaceholder text colorcolor codes (hex,rgb,rgba)false#555555
searchIconSizeSearch icon width and height sizenumberfalse20
searchIconColorSearch icon colorcolor codes (hex,rgb,rgba)false#555555
focusAfterOpenedIf true, keyboard will show after search box openedbooleanfalsefalse
shadowColorBox-shadow color of the search box. If you don't want to please type transparentcolor codes (hex,rgb,rgba)falsergba(0,0,0,0.12)
placeholderPlaceholder text of the search boxstring/texttrue
animationSpeedAnimation speeds as milisecondsarray ([number, number])false200, 250

And also supporting props all of the TextInput Component of React Native.

Events

KeyDescription
onOpeningTrigger on search box start to open
onClosingTrigger on search box start to close
onOpenedTrigger on search box fully opened
onClosedTrigger on search box fully closed

And also supporting events all of the TextInput Component of React Native.

License

React Native - Animated Searchbox is an open source project that is licensed under the MIT license.