1.1.2 • Published 2 years ago

rn-segmented-control v1.1.2

Weekly downloads
552
License
MIT
Repository
github
Last release
2 years ago

npm npm npm npm.io

SegmentedControl React Native Segmented Control for both iOS, Android and Web 😎

:anchor: Installation

npm install rn-segmented-control
yarn add rn-segmented-control

:arrows_counterclockwise: Dependencies

Make sure you have React Native Reanimated and React Native Gesture Handler installed and configured.

:wrench: Props

NameDescriptionRequiredTypeDefault
segmentsAn array of labels for segmentsYESArray[]
currentIndexIndex for the currently active segmentYESNumber0
onChangeA callback Function with pressed segment indexYESFunction() => {}
badgeValuesAn array of badge value for segments.NOArray[]
isRTLControls the toggle animation directionNOBooleanfalse
containerMarginThe value used to determine the widthNONumber16
activeTextStyleactive text stylesNOTextStyle{}
inactiveTextStyleinactive text styles.NOTextStyle{}
segmentedControlWrapperStyle object for the Segmented Control.NOViewStyle{}
pressableWrapperStyle object for the Pressable ContainerNOViewStyle{}
tileStyleStyle object for the Absolute positioned tileNOViewStyle{}
activeBadgeStyleActive Badge StyleNOViewStyle{}
inactiveBadgeStyleInactive Badge StyleNOViewStyle{}
badgeTextStyleBadge text stylesNOTextStyle{}

:warning: all View styles or Text Styles passed as props overrides some default styles provided by the package. Make sure you use it properly :)

:information_source: To apply your own shadowStyles use the tileStyle prop

:mag: Usage

import SegmentedControl from 'rn-segmented-control';

import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import SegmentedControl from './SegmentedControl';

export default function App() {
  const [tabIndex, setTabIndex] = React.useState(0);

  return (
    <View style={styles.container}>
      <View style={styles.box}>
        <SegmentedControl
          containerMargin={16}
          segments={['Label 1', 'Label 2']}
          onChange={(index) => setTabIndex(index)}
          currentIndex={tabIndex}
        />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
  },
  box: {
    marginHorizontal: 16,
    marginVertical: 16,
  },
});

Working Examples

Check the expo example app here.

:iphone: iOS and Android working Example.

SegmentedControl

:desktop_computer: Web

DesktopExample

:v: Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

:man: Author

Karthik B

:clipboard: License

MIT

1.1.1

2 years ago

1.1.0

2 years ago

1.1.2

2 years ago

0.2.9

2 years ago

0.2.8

3 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.2-rc.1

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.0-rc.2

4 years ago

0.2.1

4 years ago

0.2.0-rc.1

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.7-rc.1

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

1.0.0

5 years ago