0.0.3 • Published 7 years ago

react-native-segmented-tabs v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

react-native-segmented-tabs(for Android/iOS) 🚀

license Version npm

A react native component with the same concept of react native's SegmantedControlIOS, Primarily built to support both IOS and Android. 💡

ScreenShots

screen1

Install

npm install react-native-segmented-tabs --save

Usage

Import

import SegmentedTabs from 'react-native-segmented-tabs';

class ConsumerComponent extends Component {

  constructor (props) {
    super(props);
    this.state = {
      selectIndex: 0
    }
  }

  _selectTabs = (index) => {
    this.setState({
      selectIndex: index
    });
  }

  render() {
      return (
          <View>
            <SegmentedTabs
              wrapStyle={styles.wrap}
              selectIndex={this.state.selectIndex} 
              onPress={this._selectTabs} 
              items={['日','周','月','年']}/>
          </View>
      );
  }
}

Props

NameDescriptionDefaultType
selectIndexindex of tab item to be selected initially0number
Itemstitles of tabs['A', 'B', 'C']array
borderRadiusborderRadius of whole tab5number
wrapStyleexternal styles can be passed to override the default styles of the segmentedTabs wrapperbase styles added in SegmentedControlTab.jsobject(styles)
onPresscall-back function when a tab is selected(item) => {}function
tabHeightthe height of each of items30number
tabWidththe width of each of items80number
tabBgColorthe backgroundColor of each of items'white'string
tabActiveBgColorthe backgroundColor of active tab'#383d45'string
borderWidthborder width1number
borderColorborder color'#383d45'string
fontSizefont size16number
fontColorfont color'#383d45'string
tabActiveFontColorfont color of active item'white'string

Custom styling

    <SegmentedTabs wrapStyle={styles.tabsContainerStyle}
        tabStyle={styles.tabStyle}
        tabTextStyle={styles.tabTextStyle}
        tabHeight={30}
        tabWidth = {100}
        ...
        selectIndex={this.state.selectIndex} 
        onPress={this._selectTabs} />

    const styles = StyleSheet.create({
        tabsContainerStyle: {
          //custom styles
        }
    })

License

MIT