npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-segmented-control-ui

v1.0.3

Published

Segmented Control component for React Native

Downloads

65

Readme

react-native-segmented-control-ui(for Android/iOS) 🚀

npm Monthly Downloads

PRs Welcome

NPM

An extendable tab components for React Native similar to iOSSegmentedControl, Primarily built to support both iOS and Android.

Usage

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

const ConsumerComponent extends Component {

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

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

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

API

Name | Description | Default | Type ------|-------------|----------|----------- values | titles of tabs | ['One', 'Two', 'Three'] | array selectedIndex | index of tab item to be selected initially| [0] | number borderRadius | borderRadius of whole tab | 5 | number tabsContainerStyle | external styles can be passed to override the default styles of the segmentedControl wrapper| tabsContainerStyle | object(styles) tabStyle | external styles can be passed to override the default styles of the tabs| tabStyle | object(styles) tabTextStyle | external styles can be passed to override the default styles of the tab title| tabTextStyle | object(styles) activeTabStyle | external styles can be passed to override the default styles of the active tab| activeTabStyle | object(styles) activeTabTextStyle | external styles can be passed to override the default styles of the active tab text| activeTabTextStyle | 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 | tabBadgeContainerStyle | object(styles) activeTabBadgeContainerStyle | external style can be passed to override the default style of the active badge container | activeTabBadgeContainerStyle | object(styles) tabBadgeStyle | external style can be passed to override the default style of the badge text | tabsContainerStyle | object(styles) activeTabBadgeStyle | external style can be passed to override the default style of the active badge text | activeTabBadgeStyle | object(styles) onTabPress | call-back function when a tab is selected | () => {} | func allowFontScaling | whether the segment & badge text should allow font scaling (default matches React Native default) | true | bool accessible | enables accessibility for each tab | true | bool accessibilityLabels | Reads out the given text on each tab press when voice over is enabled. If not set, uses the text passed in as values in props as a fallback | ['Label 1', 'Label 2', 'Label 3'] | array testIDs | Unique identifier for each tab which acts as a hook for functional test | ['Label 1', 'Label 2', 'Label 3'] | array

Custom styling

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

    const styles = StyleSheet.create({
        tabsContainerStyle: {
            backgroundColor: 'transparent',
            flexDirection: 'row',
        },
        tabStyle: {
            paddingVertical: 5,
            flex: 1,
            justifyContent: 'center',
            alignItems: 'center',
            borderColor: '#0076FF',
            borderWidth: 1,
            backgroundColor: 'white',
        },
        activeTabStyle: {
            backgroundColor: '#0076FF'
        },
        tabTextStyle: {
            color: '#0076FF'
        },
        activeTabTextStyle: {
            color: 'white'
        },
        tabBadgeContainerStyle: {
            borderRadius: 20,
            backgroundColor: 'red',
            paddingLeft: 5,
            paddingRight: 5,
            marginLeft: 5,
            marginBottom: 3
        },
        activeTabBadgeContainerStyle: {
            backgroundColor: 'white'
        },
        tabBadgeStyle: {
            color: 'white',
            fontSize: 11,
            fontWeight: 'bold'
        },
        activeTabBadgeStyle: {
            color: 'black'
        }
    })
```

Try it out

You can try it out with Exponent here.

Example

Look at the example folder to run the expo app locally.

License

MIT