Nativebase: [Question] How to change Tabs background color?

Created on 20 Jun 2017  路  4Comments  路  Source: GeekyAnts/NativeBase

Hi!

In some specific cases i want to use another background color for TabHeading (not theme color).
How can i do this?! Can someone provide a short example?

Thanks.

awaiting response

Most helpful comment

@pedrogarciyalopez For this case you can use tabStyle and activeTabStyle.

import React, { Component } from 'react';
import { Container, Content, Tab, Tabs } from 'native-base';
import Tab1 from './tabOne';
import Tab2 from './tabTwo';
鈥媏xport default class TabsExample extends Component {
    render() {
        return (
            <Container>
            <Header hasTabs />
            <Tabs>
                <Tab tabStyle={{...}} activeTabStyle={{...}} heading="Tab1">
                    <Tab1 />
                </Tab>
                <Tab  tabStyle={{...}} activeTabStyle={{...}} heading="Tab2">
                    <Tab2 />
                </Tab>
                <Tab  tabStyle={{...}} activeTabStyle={{...}} heading="Tab3">
                    <Tab3 />
                </Tab>
            </Tabs>
            </Container>
        );
    }
}

Let me know if this does the trick for you

All 4 comments

@pedrogarciyalopez If you want to change background color of TabHeading for both active and inactive state, you can just do <TabHeading style={{ backgroundColor: 'blue' }}>
Or to customize it completely, you can eject native-base theme and modify as per your requirements.
https://docs.nativebase.io/Customize.html#Customize

@shivrajkumar

lets look at this code (from docs):

import React, { Component } from 'react';
import { Container, Content, Tab, Tabs } from 'native-base';
import Tab1 from './tabOne';
import Tab2 from './tabTwo';
鈥媏xport default class TabsExample extends Component {
    render() {
        return (
            <Container>
            <Header hasTabs />
            <Tabs>
                <Tab heading="Tab1">
                    <Tab1 />
                </Tab>
                <Tab heading="Tab2">
                    <Tab2 />
                </Tab>
                <Tab heading="Tab3">
                    <Tab3 />
                </Tab>
            </Tabs>
            </Container>
        );
    }
}

Let's say I want to change the backgroundColor of tab headings, just for this case, not for whole app. Can you explain on this example?

@pedrogarciyalopez For this case you can use tabStyle and activeTabStyle.

import React, { Component } from 'react';
import { Container, Content, Tab, Tabs } from 'native-base';
import Tab1 from './tabOne';
import Tab2 from './tabTwo';
鈥媏xport default class TabsExample extends Component {
    render() {
        return (
            <Container>
            <Header hasTabs />
            <Tabs>
                <Tab tabStyle={{...}} activeTabStyle={{...}} heading="Tab1">
                    <Tab1 />
                </Tab>
                <Tab  tabStyle={{...}} activeTabStyle={{...}} heading="Tab2">
                    <Tab2 />
                </Tab>
                <Tab  tabStyle={{...}} activeTabStyle={{...}} heading="Tab3">
                    <Tab3 />
                </Tab>
            </Tabs>
            </Container>
        );
    }
}

Let me know if this does the trick for you

@shivrajkumar Yes, this is exactly what i'm looking for! Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

natashache picture natashache  路  3Comments

muthuraman007 picture muthuraman007  路  3Comments

maphongba008 picture maphongba008  路  3Comments

natashache picture natashache  路  3Comments

aloifolia picture aloifolia  路  3Comments