React-native-tab-view: Tab Bar Color

Created on 22 Feb 2019  ·  4Comments  ·  Source: satya164/react-native-tab-view

Current behaviour

I have the default blue header color and the yellow underline color.

Expected behaviour

I want to add styles to the tab title and style it like a button

Code sample

`import * as React from 'react';
import { View, StyleSheet, Dimensions } from 'react-native';
import { TabView, SceneMap } from 'react-native-tab-view';

const FirstRoute = () => (

);
const SecondRoute = () => (

);
const ThirdRoute = () => (

);
export default class TabViewExample extends React.Component {
state = {
index: 0,
routes: [
{ key: 'first', title: 'First' },
{ key: 'second', title: 'Second' },
{ key: 'third', title: 'Third' },
],
};

render() {
return (
navigationState={this.state}
renderScene={SceneMap({
first: FirstRoute,
second: SecondRoute,
third:ThirdRoute
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width }}
/>
);
}
}

const styles = StyleSheet.create({
scene: {
flex: 1,
},
});`

What have you tried

I am stuck at this point since the documentation didn't we can do that.

Your Environment

| software | version
| --------------------- | -------
| ios or android | oreo
| react-native | 0.57
| react-native-tab-view | 1.3.2
| node |
| npm or yarn |

Most helpful comment

TabView style doesn't work as expected,I just need to change the backgroud color for the TabView

All 4 comments

TabBar accepts a style prop to change styles such as background color, tabStyle to style individual tabs, and indicatorStyle for indicator. If these props aren't enough for you, you can also make a custom tab bar https://snack.expo.io/@satya164/react-native-tab-view-custom-tabbar

navigationState={this.state}
renderScene={SceneMap({
first: FirstRoute,
second: SecondRoute,
third:ThirdRoute
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width }}
style={{backgroundColor:'#333333'}}
/>

check this code, I used TabView and adding a style to the TabView still changes nothing here.The color is still blue.Assist

TabView style doesn't work as expected,I just need to change the backgroud color for the TabView

como se cambia el color, tengo que usar tabBar??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glennvgastel picture glennvgastel  ·  3Comments

moerabaya picture moerabaya  ·  4Comments

QuentinBrosse picture QuentinBrosse  ·  4Comments

satya164 picture satya164  ·  3Comments

chen504554911 picture chen504554911  ·  3Comments