0.1.2 • Published 5 years ago

@xiaolongshen/react-native-segment-tab v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

react-native-segment-tab(for Android/iOS)

segment-tab looks like ios component

npm.io

Install

npm install react-native-segment-tab --save

Usage

  state = {
    selected: 0
  }
  render() {
    return (
      <View style={styles.container}>
        <SegmentTab
          data={['Day1', 'Day2', 'Day3']}
          selected={this.state.selected}
          onPress={ index => this.setState({selected: index})}
        />
        <SegmentTab
          style={{marginTop: 40}}
          activeColor='#4078bf'
          selected={this.state.selected}
          onPress={ index => this.setState({selected: index})}
          orientation='vertical'
        />
      </View>
    );
  }

Props

NameDescriptionDefaultType
datatitles of tabs['One', 'Two', 'Three']array
titleSizefontSize for each title14number
orientationdirection of tabsvertical or horizontalstring
horizontalWidthwidth of tab when tab is horizontal layout200number
horizontalHeightheight of tab when tab is horizontal layout40number
verticalWidthwidth of tab when tab is vertical layout100number
verticallHeightheight of tab when tab is vertical layout120number
borderRadiusborderRadius of whole tab5number
borderColorborderColor of whole tabgraystring
activeColorcolor of an active tab itemredstring
inActiveColorcolor of an inActive tab item, it will be color of its parent's backgroundColor if is nullnullstring
textActiveColortext of color in active tabinActiveColorstring
textInActiveColortext of color in inactive tabactiveColorstring
selectedindex of selected tab item0number
tyleyou can add external for tabnullView.propTypes.style
onPresscall-back function for each item() => {}func

Notice:

  • Following idea of stateless component, react-native-segment-tab is designed without internal state, so you have to use selected and onPress props to response your interaction.
  • You'd better use the component with a wrapper view because segment-tab is a pure component.
  • If you have any question, just create issues or send email to me: poberwong@gmail.com.

License

MIT