Skip to content

Repository files navigation

Swith in React-Native

Battle Tested ✅

npm version

Platform - Android and iOSLicense: MITstyled with prettier

Swith in React-Native

Installation

Add the dependency:

npmiswitchin-react-native

Peer Dependencies

IMPORTANT! You need install them

Zero Dependency

Usage

Import

importDuoToggleSwitchfrom"switchin-react-native";

Basic Usage

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

OR (Also you can add icon like this)

<DuoToggleSwitchprimaryText={<Feathername="grid"size={24}color={'black'}/>}secondaryText={<Feathername="menu"size={24}color={'black'}/>}onPrimaryPress={()=>{}}onSecondaryPress={()=>{}}/>

Custom Usage

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

Configuration - Props

TouchableComponent?: any;

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

Author

Ravindra Nakrani, 0330.ravindra@gmail.com

License

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

About

Fully customizable animated toggle switch for React Native

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages