React Native Material Appbar With Header Component Example

04-Apr-2023

.

Admin

React Native Material Appbar With Header Component Example

Hi Guys,

In this blog, I will explain you how to create material ui appbar with header component in react native. You can easily create material ui appbar with header component in react native. First i will import stylesheet namespace from react-native-paper, after I will make material ui appbar using in react native.

Here, I will give you full example for simply display material ui appbar with header component using react native as bellow.

Step 1 - Create project


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

expo init MaterialUIAppbarHeader

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 * as React from 'react';

import { Appbar } from 'react-native-paper';

import { StyleSheet } from 'react-native';

const AppbarWithHeaderExample = () => {

const _jumpToBack = () => {

alert('Jump back');

}

const _filter = () => {

alert('Filtering');

}

const _more = () => {

alert('Show more');

}

return (

<Appbar.Header style={styles.header}>

<Appbar.BackAction onPress={_jumpToBack} />

<Appbar.Content title="Events" />

<Appbar.Action icon="magnify" onPress={_filter} />

<Appbar.Action icon="dots-vertical" onPress={_more} />

</Appbar.Header>

);

};

export default AppbarWithHeaderExample;

const styles = StyleSheet.create ({

header: {

backgroundColor : "teal"

}

})

Step 4 - Run project

In the last step run your project using bellow command.

npm start

Output

It will help you...

#React Native