0.1.0 • Published 2 years ago

react-native-toggle-button v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native Toggle Button

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

Installation

Add the dependency:

npm i react-native-toggle-button

Peer Dependencies

Zero Dependency

Usage

Import

import ToggleButton from "react-native-toggle-button";

Fundamental Usage

<ToggleButton
  primaryText="On"
  secondaryText="Off"
  onPress={(isToggled: boolean) => {
    console.log(isToggled);
  }}
/>

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

PropertyTypeDefaultDescription
primaryTextstringundefinedchange the primaryText
secondaryTextstringundefinedchange the secondaryText
onPressfunctionundefinedset your own logic for the button functionality when it is pressed

Customization (Optionals)

PropertyTypeDefaultDescription
inialbooleantruelet you change the initial toggled value
styleViewStyledefaultset or override the style object for the main container
activeButtonStyleViewStyledefaultset or override the style object for the active button style
inactiveButtonStyleViewStyledefaultset or override the style object for the inactive button style
activeTextStyleTextStyledefaultset or override the style object for the active text style
inactiveTextStyleTextStyledefaultset or override the style object for the inactive text style
TouchableComponentTouchableWithoutFeedbackdefaultset your own component instead of default react-native TouchableWithoutFeedback component

Future Plans

  • LICENSE
  • Write an article about the lib on Medium

Author

FreakyCoder, kurayogun@gmail.com

License

React Native Toggle Button is available under the MIT license. See the LICENSE file for more info.