Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling react-native Navigation Drawer Items

How To styling react-native navigation drawer item's Text.I go through the Documentation but i didnt able to find correct way to do that

Navigation Documentation

This is My AppContainer

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { View, Text, Button, StyleSheet } from 'react-native';
import { bindActionCreators } from 'redux';
import { ActionCreators } from '../actions';
import Home_ from './Home';
import About from './About';
//Add navigation
import { DrawerNavigator, DrawerItems} from 'react-navigation'

const cunstomeDrawerContentComponent = (props) => (
    <View style={{flex: 1, color: 'red',
        textAlign: 'center',
        fontSize: 30,
        fontFamily: 'cochin',
        letterSpacing: 4}} >
        <DrawerItems {...this.props} />
    </View>
);

const drawerLayout = DrawerNavigator({
    Home: { screen: Home_ },
    About: { screen: About },

});

function mapDispatchToProps(dispatch) {
    return bindActionCreators(ActionCreators, dispatch);
}

const styles = StyleSheet.create({
    container: {
        flex: 1, color: 'red',
        textAlign: 'center',
        fontSize: 30,
        fontFamily: 'cochin',
        letterSpacing: 4
    }


});

export default connect((state) => { return {} }, mapDispatchToProps)(drawerLayout);
like image 641
maddy Avatar asked May 04 '17 02:05

maddy


People also ask

How do you style drawer items in React Native?

You just need to add some props to DrawerItems component. like below. I have customised it with sample values. Update your code and apply whatever font color and background color you want.

How do you customize the drawer navigation in React Native?

React Navigation is a powerful library that helps us create Stack navigation, Drawer navigation and Tab navigation in our React Native apps. To create a simple side menu all we need to do is create a DrawerNavigator and pass in the route configuration and drawer configuration.

How do you use the navigation drawer in React Native?

Step 1: Open your terminal and install expo-cli by the following command. Step 2: Now create a project by the following command. Step 4: Now install react-navigation into your project. React Navigation is used to navigate between one page to another.


2 Answers

You just need to add some props to DrawerItems component. like below.

<DrawerItems {...this.props}  activeTintColor='#2196f3' activeBackgroundColor='rgba(0, 0, 0, .04)' inactiveTintColor='rgba(0, 0, 0, .87)' inactiveBackgroundColor='transparent' style={{backgroundColor: '#000000'}} labelStyle={{color: '#ffffff'}}/>

I have customised it with sample values. Update your code and apply whatever font color and background color you want.

like image 78
Irfan Ali Avatar answered Sep 26 '22 20:09

Irfan Ali


Please Tak a look at this document. check the contentOptions properties.

like image 23
Sochetra Nov Avatar answered Sep 22 '22 20:09

Sochetra Nov