Giter Site home page Giter Site logo

wrathchaos / react-native-segmented-control-2 Goto Github PK

View Code? Open in Web Editor NEW
29.0 3.0 4.0 4.21 MB

🚀 React Native Segmented Control, Pure Javascript for iOS and Android

Home Page: https://freakycoder.com

JavaScript 13.72% Shell 0.33% Starlark 1.32% Java 33.55% Ruby 2.79% Objective-C 5.25% TypeScript 16.36% Makefile 3.35% C++ 15.32% Objective-C++ 8.02%
android app-dev app-development apple application development freakycoder google ios javascript

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

React Native Segmented Control 2

React Native Segmented Control 2

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

React Native Segmented Control 2

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)}
/>

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

Customization (Optionals)

Property Type Default Description
style ViewStyle default set or override the style object for the main container
width number ScreenWidth * 0.9 change the width of the main segmented control
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
extraSpacing 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
textStyle TextStyle default set or override the style object for tab's text

Future Plans

  • LICENSE
  • 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

Author

FreakyCoder, [email protected]

License

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

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

Contributors

b0iq avatar wrathchaos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-segmented-control-2's Issues

size too big for android

Ảnh chụp Màn hình 2022-09-01 lúc 00 03 01

Hi can u help my problem, here is my code:

 <SegmentedControl
            style={{
                backgroundColor:'whitesmoke'
            }}
            tabs={[language.AllCallHistory, language.MissingCallOnly]}
            onChange={(index) => {
                console.log('on change', index)
            }}
            activeTextColor={'white'}
            activeTabColor={'orange'}
        />

no LICENSE file

Hey, I modified your implementation to suit my use case, but I don't see any LICENSE file linked to your name in this repository.

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.