GithubHelp home page GithubHelp logo

lany9527 / react-native-segmented-control-tab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kirankalyan5/react-native-segmented-control-tab

0.0 2.0 0.0 178 KB

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

License: MIT License

JavaScript 62.86% Python 8.60% Java 6.55% Objective-C 21.99%

react-native-segmented-control-tab's Introduction

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

npm Monthly Downloads GitHub stars PRs Welcome

NPM

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

ScreenShots

screen1

screen2

Screen3

Install

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

Usage

IMPORTANT

This has been made into a controlled component from 3.0. Those who are familiar with 2.0, read below for the updated usage.

import SegmentedControlTab from 'react-native-segmented-control-tab'

class ConsumerComponent extends Component {

    constructor(){
      super()
      this.state = {
        selectedIndex: 0,
      };
    }

    handleIndexChange = (index) => {
      this.setState({
        ...this.state,
        selectedIndex: index,
      });
    }

    render() {
        return (
            <View>
                <SegmentedControlTab
                    values={['First', 'Second', 'Third']}
                    selectedIndex={this.state.selectedIndex}
                    onTabPress={this.handleIndexChange}
                    />
            </View>
        );
    }
}

Props

Name Description Default Type
values titles of tabs ['One', 'Two', 'Three'] array
selectedIndex index of tab item to be selected initially [0] number
selectedIndices Array of indices of tab items to be selected initially - when multiple prop is true else it will take selectedIndex [0] arrayOf(PropTypes.number)
multiple Boolean which enables the multiple selection option false bool
borderRadius borderRadius of whole tab 5 number
tabsContainerStyle external styles can be passed to override the default styles of the segmentedControl wrapper base styles added in SegmentedControlTab.js object(styles)
tabStyle external styles can be passed to override the default styles of the tabs base styles added in SegmentedControlTab.js object(styles)
tabTextStyle external styles can be passed to override the default styles of the tab title base styles added in SegmentedControlTab.js object(styles)
activeTabStyle external styles can be passed to override the default styles of the active tab base styles added in SegmentedControlTab.js object(styles)
activeTabTextStyle external styles can be passed to override the default styles of the active tab text base styles added in SegmentedControlTab.js object(styles)
badges badges values to display [1, 2, 3] array
tabBadgeContainerStyle external style can be passed to override the default style of the badge container base styles added in SegmentedControlTab.js object(styles)
activeTabBadgeContainerStyle external style can be passed to override the default style of the active badge container base styles added in SegmentedControlTab.js object(styles)
tabBadgeStyle external style can be passed to override the default style of the badge text base styles added in SegmentedControlTab.js object(styles)
activeTabBadgeStyle external style can be passed to override the default style of the active badge text base styles added in SegmentedControlTab.js object(styles)
onTabPress call-back function when a tab is selected () => {} func

Custom styling

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

    const styles = StyleSheet.create({
        tabsContainerStyle: {
          //custom styles
        },
        tabStyle: {
          //custom styles
          },
        tabTextStyle: {
          //custom styles
        },
        activeTabStyle: {
          //custom styles
          },
        activeTabTextStyle: {
          //custom styles
        },
        tabBadgeContainerStyle: {
          //custom styles
        },
        activeTabBadgeContainerStyle: {
          //custom styles
        },
        tabBadgeStyle: {
          //custom styles
        },
        activeTabBadgeStyle: {
          //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 raise a PR.๐Ÿ˜Š๐Ÿš€

License

MIT

react-native-segmented-control-tab's People

Contributors

8of avatar alexdunae avatar asessa avatar ashoat avatar jgplane avatar kirankalyan5 avatar suhairzain avatar terrysahaidak avatar

Watchers

 avatar  avatar

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.