question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Style Tabbar with Icons

See original GitHub issue

Hi, I have a Tabbar with icons and Text i am facing 2 problems: 1-Text doesn’t go to the bottom of the icon 2-ActiveTabStyle doesn’t apply on tabs so i can’t style my tabs her is my code `

     <Tabs tabBarPosition = "bottom" {...tabProps}>

                    <Tab heading = {<TabHeading>
                            <Icon name="home"/>
                        <Text>Acheter</Text>
                    </TabHeading>}
                         tabStyle = {{backgroundColor: 'transparent'}}
                         activeTabStyle = {{backgroundColor: 'transparent'}}
                         activeTextStyle = {{fontWeight:'bold', color: '#651FFF', fontSize:17}}
                         textStyle = {{color: '#7C4DFF', fontWeight: 'bold', fontSize:16}}
                    >
                        <ProduitsScene style ={{ marginTop: -2}}/>
                    </Tab>

                    <Tab heading = {<TabHeading><Icon name="briefcase"/></TabHeading>}>
                    </Tab>

                    <Tab heading = {<TabHeading><Icon name="ios-menu-outline"/></TabHeading>}>
                    </Tab>

                    <Tab heading = {<TabHeading><Icon name="ios-compass-outline"/></TabHeading>}>
                    </Tab>

                    <Tab heading = {<TabHeading><Icon name="person"/></TabHeading>}>
                    </Tab>
                </Tabs>

`

her is a screen of my tabs capture d ecran 2017-06-13 a 15 45 28

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
shivrajkumarcommented, Jun 20, 2017

try <TabHeading style={{ flexDirection: 'column' }}><Icon name="briefcase"/><Text>Tab Text</Text></TabHeading>

4reactions
akhil-gacommented, Mar 6, 2018

@PdxMehmet @Elitebigboss90 posting code for the common case without <TabHeading/>

Code

import React, { Component } from 'react';
import { Container, Header, Content, Tab, Tabs, Text } from 'native-base';
export default class TabsExample extends Component {
  render() {
    return (
      <Container>
        <Header hasTabs />
        <Tabs initialPage={1} >
          <Tab heading="Tab1" tabStyle={{ backgroundColor: 'transparent' }}
            activeTabStyle={{ backgroundColor: 'transparent' }}
            activeTextStyle={{ fontWeight: 'bold', color: '#651FFF', fontSize: 17 }}
            textStyle={{ color: '#7C4DFF', fontWeight: 'bold', fontSize: 16 }}>
            <Text>Tab one</Text>
          </Tab>
          <Tab heading="Tab2"
            tabStyle={{ backgroundColor: 'transparent' }}
            activeTabStyle={{ backgroundColor: 'transparent' }}
            activeTextStyle={{ fontWeight: 'bold', color: '#651FFF', fontSize: 17 }}
            textStyle={{ color: '#7C4DFF', fontWeight: 'bold', fontSize: 16 }}>
            <Text>Tab two</Text>
          </Tab>
          <Tab heading="Tab3"
            tabStyle={{ backgroundColor: 'transparent' }}
            activeTabStyle={{ backgroundColor: 'transparent' }}
            activeTextStyle={{ fontWeight: 'bold', color: '#651FFF', fontSize: 17 }}
            textStyle={{ color: '#7C4DFF', fontWeight: 'bold', fontSize: 16 }}>
            <Text>Tab three</Text>
          </Tab>
        </Tabs>
      </Container>
    );
  }
}

Gif

tab styling

handling style programmatically while using <Tabheading/>

Code

import React, { Component } from 'react';
import { Container, Header, Content, Tab, Tabs, Text, TabHeading, Icon } from 'native-base';
import { StyleSheet } from 'react-native'
export default class TabsExample extends Component {

  constructor(props) {
    super(props)
    this.state = { page: 1 }
  }

  render() {
    return (
      <Container>
        <Header hasTabs />
        <Tabs initialPage={1} onChangeTab={({ i }) => this.setState({ page: i })}>
          <Tab heading={<TabHeading style={this.state.page === 0 ? styles.activeTabStyle : styles.tabStyle}>
            <Icon name="camera" />
            <Text style={this.state.page === 0 ? styles.activeTextStyle : styles.textStyle}>Camera</Text>
          </TabHeading>}>
            <Text>Tab one</Text>
          </Tab>
          <Tab heading={<TabHeading style={this.state.page === 1 ? styles.activeTabStyle : styles.tabStyle}>
            <Text style={this.state.page === 0 ? styles.activeTextStyle : styles.textStyle}>No Icon</Text>
          </TabHeading>}>
            <Text>Tab two</Text>
          </Tab>
          <Tab heading={<TabHeading style={this.state.page === 2 ? styles.activeTabStyle : styles.tabStyle}>
            <Icon name="apps" />
          </TabHeading>}>
            <Text>Tab three</Text>
          </Tab>
        </Tabs>
      </Container >
    );
  }
}

const styles = StyleSheet.create({
  tabStyle: { backgroundColor: 'transparent' },
  activeTabStyle: { backgroundColor: 'transparent' },
  activeTextStyle: { fontWeight: 'bold', color: '#651FFF', fontSize: 17 },
  textStyle: { color: '#7C4DFF', fontWeight: 'bold', fontSize: 16 }
})

Gif

tab styling2

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native: Tab bar is customizable | by Alex Melnyk
A few days ago I found a simple but complicated gif from UX Planet post with a customized TabBar it was inspired me...
Read more >
How to make the overflow of tab bar icon clickable in react ...
The Problem: The Red icon is only clickable within the tab bar range, once i have crossed the grey line of the tab...
Read more >
How to Create a Custom Tab Bar in React Native - Crowdbotics
At this point, we haven't added any custom styles to the tab bar, so it has a default style from the React Navigation...
Read more >
Bottom Tabs Navigator | React Navigation
A simple tab bar on the bottom of the screen that lets you switch between different routes. ... tabBarBadgeStyle ​. Style for the...
Read more >
Tab bars - Navigation and search - Human Interface Guidelines
A screenshot of the Photos app on an iPhone in landscape orientation. Each tab in. If you need to create custom tab bar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found