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 ๐Ÿ™

ยฉ 2025 โ€“ย Pkg Stats / Ryan Hefner

react-native-segmented-control-2

v2.1.1

Published

๐Ÿš€ React Native Segmented Control, Pure Javascript for iOS and Android

Readme

React Native Segmented Control 2

npm version npm Platform - Android and iOS License: MIT styled with prettier

Installation

Add the dependency:

npm i react-native-segmented-control-2

Peer Dependencies

Zero Dependency ๐Ÿฅณ

Usage

Import

import SegmentedControl from "react-native-segmented-control-2";

Fundamental Usage

<SegmentedControl
  tabs={["Label 1", "Label 2", "Label 3"]}
  onChange={(index: number) => console.log("Index: ", index)}
/>

As controlled component:

const [index, setIndex] = useState(0)
return (
  <SegmentedControl
    tabs={["Label 1", "Label 2", "Label 3"]}
    onChange={setIndex}
    value={index}
  />
)

Customized Usage

<SegmentedControl
  style={{ marginTop: 32, backgroundColor: "#ffe0e0" }}
  activeTabColor="#ff2929"
  activeTextColor="#fff"
  tabs={["Label 1", "Label 2", "Label 3"]}
  onChange={(index: number) => console.log("Index: ", index)}
/>

Any Component Usage

You can use the segmented control with any component. All you need to do is that put any component into the tabs props. Please check out the example for its usage

Example Project ๐Ÿ˜

You can checkout the example project ๐Ÿฅฐ

Simply run

  • npm i
  • react-native run-ios/android

should work of the example project.

Configuration - Props

Fundamentals

| Property | Type | Default | Description | | -------- | :------: | :-------: | ---------------------------------------------------- | | tabs | any[] | undefined | set the array for tabs | | onChange | function | undefined | set your own logic when the tab is pressed / changed | | value | number | undefined | value of index if used as a controlled component |

Customization (Optionals)

| Property | Type | Default | Description | |------------------|:---------:|:-------:|------------------------------------------------------------| | style | ViewStyle | default | set or override the style object for the main container | | initialIndex | number | 0 | set the initial index | | activeTextColor | string | #000 | change the active tab's text color | | activeTabColor | string | #FFF | change the active tab's color | | gap | number | 0 | set extra spacing for animation horizontal value | | tabStyle | ViewStyle | default | set or override the style object for the tab | | selectedTabStyle | ViewStyle | default | set or override the style object for the selected tab | | activeTextStyle | TextStyle | default | set or override the style object for the active tab's text | | textStyle | TextStyle | default | set or override the style object for tab's text |

Future Plans

  • [x] ~~LICENSE~~
  • [x] ~~Controller component support~~ (Thanks to @madox2 (https://github.com/WrathChaos/react-native-segmented-control-2/pull/6))
  • [x] ~~Getting rid of screen width and manual width dependencies~~ (Thanks to @philo23 (https://github.com/WrathChaos/react-native-segmented-control-2/pull/7)
  • [ ] Write an article about the lib on Medium

Credits

Heavily inspired by these libraries:

I created this library because they're really not maintain actively and this is a pure javascript written library with a lot of customizations and better code structure

Author

FreakyCoder, [email protected]

License

React Native Segmented Control 2 is available under the MIT license. See the LICENSE file for more info.