1.0.0 • Published 6 years ago

react-native-segment-controller v1.0.0

Weekly downloads
523
License
ISC
Repository
github
Last release
6 years ago

react-native-segment-controller npm version

A react-native segment controller for both android and ios. You can define any number of tabs or segemnts and this will automatically adjust according to the wrapped view's width. You can also add badge count to specify any integer to user.

Demo

Alt text

Installation

yarn add react-native-segment-controller  or npm install --save react-native-segment-controller

Usage

import SegmentControl from 'react-native-segment-controller';

 <SegmentControl
          values={['One', 'Two', 'Three', 'Four']}
          badges={[0, 5, 0, 2]}
          selectedIndex={0}
          height={30}
          onTabPress={() => {}}
          borderRadius={5}
 />

Prop-types

Prop nameType
valueslist - list of names for Tabs
badgeslist - list of integers matching to defined tab names corresponding to indicate any badge count need to be specified
onTabPressfunction - this returns the selected tab index
selectedIndexint - indicates the selected tab index corresponding to given values list
tabsContainerStyleint - radius of the container
tabBadgeContainerStyleobject - styles for view
activeTabBadgeContainerStyleobject - styles for view
tabBadgeStyleobject - styles for view
activeTabBadgeStyleobject - styles for view
borderRadiusint - radius of the container
tabStyleobject - styles for view
activeTabStyleobject - styles for view
tabTextStyleobject - styles for Text
activeTabTextStyleobject - styles for Text
heightint - height in number of pixels

Example

checkout sample directory and findout a react-native app. First run npm install or yarn

then run

react-native run-android  or  react-native run-ios

Created by @ Chanaka Athurugiriya