1.0.1 • Published 9 years ago

react-native-segemented-control-tab v1.0.1

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

react-native-segmented-control-tab(for Android/iOS) šŸš€

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

ScreenShots

screen1.png screen2.png

Install

npm install react-native-segmented-control-tab --save

Usage

class ConsumerComponent extends Component {
    constructor(props) {
        super(props)
        this.state = {
            selected: 0
        }
    }
    render() {
        return (
            <View>
                <SegmentedControlTab tabsContainerStyle={styles.tabsContainerStyle}
                    selectedIndex={this.state.selected}
                    values={['First', 'Second', 'Third']}
                    onPress= {index => this.setState({selected:index})}
                    />
            </View>)
    }
}

Props

NameDescriptionDefaultType
valuestitles of tabs['One', 'Two', 'Three']array
activeColorcolor of an active tab item#0076FFstring
inActiveColorcolor of an inActive tab itemwhitestring
textActiveColortext of color in active tab#0076FFstring
borderRadiusborderRadius of whole tab5number
textInActiveColortext of color in inactive tabwhitestring
selectedindex of selected tab item0number
tabsContainerStyleexternal styles can be passed to override the default styles of the segmentedControl wrapperbase styles added in SegmentedControlTab.jsobject(styles)
tabStyleexternal styles can be passed to override the default styles of the tabsbase styles added in SegmentedControlTab.jsobject(styles)
tabTitleStyleexternal styles can be passed to override the default styles of the tab titlebase styles added in SegmentedControlTab.jsobject(styles)
onPresscall-back function for each item() => {}func

Custom styling

    <SegmentedControlTab tabsContainerStyle={styles.tabsContainerStyle}
        tabStyle={styles.tabStyle}
        tabTitleStyle={styles.tabTitleStyle}
        selectedIndex={this.state.selected}
        values={['First', 'Second', 'Third']}
        onPress= {index => this.setState({selected:index})}
        />

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

##P.S. šŸ™ credits to all the other devs who had built the similar concept, had referred some of the their components on the github, to get a fair idea šŸ’” to build this.😊 If you have any idea in implementing this further, let me know or you can update it and rise a PR.šŸ˜ŠšŸš€

License

MIT