React Native Duo Toggle Switch | Expo

0

 React Native Duo Toggle Switch

Battle Tested ✅

Fully customizable animated duo toggle switch for React Native

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

React Native Duo Toggle Switch

Version 1 ðŸ¥°

Version 1 is released with typescript and some breaking changes

  • Code Cleaning
  • Typescript
  • Better props
  • Fully customizable
  • Better animations
  • Better GIFs on documentation

Installation

Add the dependency:

npm i react-native-duo-toggle-switch

Peer Dependencies

IMPORTANT! You need install them

Zero Dependency

Usage

Import

import DuoToggleSwitch from "react-native-duo-toggle-switch";

Basic Usage

<DuoToggleSwitch
  primaryText="Map"
  secondaryText="List"
  onPrimaryPress={() => {}}
  onSecondaryPress={() => {}}
/>

Custom Usage

<DuoToggleSwitch
  primaryText="Map"
  secondaryText="List"
  onPrimaryPress={() => {}}
  onSecondaryPress={() => {}}
  TouchableComponent={Ripple}
  rippleColor="#fff"
  rippleContainerBorderRadius={50}
/>

Configuration - Props

PropertyTypeDefaultDescription
primaryTextstringundefinedset the primary button's (left one) text
secondyTextstringundefinedset the secondy button's (right one) text
activeColorstring#FBA928change the button's background color when it is active or pressed
inactiveColorstring#fffchange the button's background color when it is inactive or pressed
activeTextColorstring#f1f1f1change the button's text color when it is active or pressed
inactiveTextColorstring#757575change the button's text color when it is active or pressed
onPrimaryPressfunctionnullset your own onPress logic for first(primary) button
onSecondaryPressfunctionnullset your own onPress logic for second(secondary) button
styleViewStyledefaultset or override style for the main container
primaryButtonStyleViewStyledefaultset or override style for the primary button
secondaryButtonStyleViewStyledefaultset or override style for the secondary button
primaryTextStyleTextViewdefaultset or override style for primary text style
secondaryTextStyleTextViewdefaultset or override style for secondary text style
TouchableComponentcomponentTouchableOpacityset your own Pressable functionality instead of TouchableOpacity

Future Plans

  •  LICENSE
  •  Typescript
  •  Color Change Animation
  •  Write an article about the lib on Medium

Author

FreakyCoder, kurayogun@gmail.com

License

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




Post a Comment

0Comments
Post a Comment (0)