React Native Paper TextInput With Icon Example

May 22, 2021 . Admin

Hi Guys,

Nowadays, I can learn you how to engender paper textinput with icon in react native. you can facilely engender paper textinput with icon in react native. First, i will import stylesheet namespace from react-native-paper, after i can make paper textinput with icon making use of in react native.

Right Here, I'm able to give you full example for truly show off paper textinput with icon utilising react native as bellow.

Step 1 - Create project

In the first step Run the following command for create project.

expo init PaperTextInputWithIcon
Step 2 - Install Package

In the step,I will install npm i react-native-paper package.

npm i react-native-paper
Step 3 - App.js

In this step, You will open App.js file and put the code.

import React, { Component } from "react";
import { Text, View,StyleSheet} from 'react-native';
import { Provider ,Appbar,Card,textinput with icon} from 'react-native-paper';

const MyWebtutsComponent = () => {

   const [searchQuery, setSearchQuery] = React.useState('');

  const onChangeSearch = query => setSearchQuery(query);

  const _goBack = () => console.log('Went back');

  const _handleSearch = () => console.log('Searching');

  const _handleMore = () => console.log('Shown more');

  return (
    <Provider>
    <Appbar.Header style={styles.header}>
      <Appbar.BackAction onPress={_goBack} />
      <Appbar.Content title="User" subtitle="Subtitle" />
      <Appbar.Action icon="magnify" onPress={_handleSearch} />
      <Appbar.Action icon="dots-vertical" onPress={_handleMore} />
    </Appbar.Header>
      <View style={styles.mainbox}>
       <Card>
        <textinput with icon
            placeholder="Search"
            onChangeText={onChangeSearch}
            value={searchQuery}
          />
       </Card>
      </View>
    </Provider>
  );
};


const styles = StyleSheet.create({
  title:{
    margin: 10,
    fontSize: 15,
    fontSize: 35
  },
  mainbox:{
    textAlign:'center',
    margin: 15,
    flex: 1,
    justifyContent: 'space-between',
  },
  databeBox:{
    margin: 10,
    textAlign: 'center',
  },
  databeHeader:{
    margin: 10,
    textAlign: 'left', 
  }
});
export default MyWebtutsComponent;
Step 4 - Run project

In the last step run your project using bellow command.

npm start
Output

It will help you...

#React Native