React-native-tab-view: How to show tab lebel in small Letter

Created on 22 Aug 2017  路  4Comments  路  Source: satya164/react-native-tab-view

Expected behaviour

How to change tab text from upper case to lower case: 'First','Second'

Actual behaviour

Currently, All tabs appear in Upper case for ex: 'FIRST','SECOND'

Code sample, screenshots

routes: [
{ key: '1', title: 'Status' },
{ key: '2', title: 'Media' },
{ key: '3', title: 'Log' },
],

What have you tried

Most helpful comment

You can use the renderLabel prop like this:

state = {
    index: 0,
    routes: [
      { key: '1', title: 'Tab One', icon: 'tab-one-icon' },
      { key: '1', title: 'Tab Two', icon: 'tab-two-icon' }
    ]
  };

_renderLabel = ({ route }) => (
    <Text style={s.tabBarLabel}>{route.title}</Text>
  );

<TabBar
      renderLabel={this._renderLabel}
      ...
      {...props}
    />

All 4 comments

+1

You can use the renderLabel prop like this:

state = {
    index: 0,
    routes: [
      { key: '1', title: 'Tab One', icon: 'tab-one-icon' },
      { key: '1', title: 'Tab Two', icon: 'tab-two-icon' }
    ]
  };

_renderLabel = ({ route }) => (
    <Text style={s.tabBarLabel}>{route.title}</Text>
  );

<TabBar
      renderLabel={this._renderLabel}
      ...
      {...props}
    />

Use getLabelText

Here are two examples of a renderFooter callback, one with renderLabel and one with getLabelText.

Example with renderLabel:

_renderFooter(props) {

  _renderLabel = ({ route }) => (
    <Text style={styles.tablabel}>{route.title}</Text>
  );

  return (
    <TabBar 
      {...props} 
      style={styles.tabbar}
      tabStyle={styles.tab}
      renderLabel={this._renderLabel}
    />
  )
}

Example with getLabelText:

_renderFooter(props) {

  _getLabelText = ({ scene }) => (
    'you probably want to do something dynamic here'
  );

  return (
    <TabBar 
      {...props} 
      style={styles.tabbar}
      tabStyle={styles.tab}
      getLabelText={this._getLabelText}
    />
  )
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

KingAmo picture KingAmo  路  3Comments

AndriiUhryn picture AndriiUhryn  路  3Comments

QuentinBrosse picture QuentinBrosse  路  4Comments

nastarfan picture nastarfan  路  3Comments

jasonkw9 picture jasonkw9  路  3Comments