0.1.1 • Published 3 years ago

@freakycoder/react-native-switch-button v0.1.1

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

Battle Tested ✅

React Native Switch Button

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

Installation

Add the dependency:

npm i @freakycoder/react-native-switch-button

Peer Dependencies

"@freakycoder/react-native-bounceable": ">= 0.2.5"

Usage

Import

import SwitchButton from "@freakycoder/react-native-switch-button";

Fundamental Usage

<SwitchButton
  text="Notification"
  inactiveImageSource={require("./assets/notification.png")}
  activeImageSource={require("./assets/notification-3.png")}
  onPress={(isActive: boolean) => console.log(isActive)}
/>

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

PropertyTypeDefaultDescription
textstringundefinedset the text of the button
activeImageSourceImage Sourceundefinedset the active image source
inactiveImageSourceImage Sourceundefinedset the inactive image source
isActivebooleanfalseset the active state initially
onPressfunctiondefaultset your own logic for onPress functionality
mainColorstring#f1bb7bchange the main animated color
originalColorstring#fffchange the original/default animated color
tintColorstring#f1bb7bchange the tint color for the image
disableTextbooleanfalsedisable the text part if you only want to use switch button itself
styleViewStyledefaultset or override the style object for the main container
textStyleTextStyledefaultset or override the style object for the text
imageStyleImageStyledefaultset or override the style object for the image
textContainerStyleViewStyledefaultset or override the style object for text container

Future Plans

  • LICENSE
  • Write an article about the lib on Medium

Author

FreakyCoder, kurayogun@gmail.com

License

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