GithubHelp home page GithubHelp logo

grgmgd / react-native-segmented-control Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karthik-b-06/react-native-segmented-control

0.0 0.0 0.0 31.93 MB

๐ŸŽ‰ React Native Segmented Control ๐ŸŽฎ for both iOS, Android and Web

Home Page: https://www.npmjs.com/package/rn-segmented-control

License: MIT License

JavaScript 14.92% TypeScript 85.08%

react-native-segmented-control's Introduction

React Native Segmented Control

npm npm npm

SegmentedControl React Native Segmented Control for both iOS, Android and Web ๐Ÿ˜Ž

โš“ Installation

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

๐Ÿ”„ Dependencies

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

๐Ÿ”ง Props

Name Description Required Type Default
segments An array of labels for segments YES Array []
currentIndex Index for the currently active segment YES Number 0
onChange A callback Function with pressed segment index YES Function () => {}
badgeValues An array of badge value for segments. NO Array []
isRTL Controls the toggle animation direction NO Boolean false
containerMargin The value used to determine the width NO Number 16
activeTextStyle active text styles NO TextStyle {}
inactiveTextStyle inactive text styles. NO TextStyle {}
segmentedControlWrapper Style object for the Segmented Control. NO ViewStyle {}
pressableWrapper Style object for the Pressable Container NO ViewStyle {}
tileStyle Style object for the Absolute positioned tile NO ViewStyle {}
activeBadgeStyle Active Badge Style NO ViewStyle {}
inactiveBadgeStyle Inactive Badge Style NO ViewStyle {}
badgeTextStyle Badge text styles NO TextStyle {}

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

โ„น๏ธ To apply your own shadowStyles use the tileStyle prop

๐Ÿ” 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.

๐Ÿ“ฑ iOS and Android working Example.

SegmentedControl

๐Ÿ–ฅ๏ธ Web

DesktopExample

โœŒ๏ธ Contributing

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

๐Ÿ‘จ Author

Karthik B

๐Ÿ“‹ License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.