1.0.0 • Published 4 months ago

@splicer97/react-native-switch v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

react-native-switch npm version Downloads

Custom Switch component for React Native that use Reanimated and Gesture Handler

example.gif.

Installation

First, you need to install and configure the Reanimated and Gesture Handler libraries

Then install library

npm install @splicer97/react-native-switch

or

yarn add @splicer97/react-native-switch

Usage

import Switch from '@splicer97/react-native-switch';

// ...
const [state, setState] = useState(false);

return (
  <GestureHandlerRootView style={{ flex: 1 }}>
    <View style={styles.container}>
      <Switch value={state} onValueChange={setState} />
    </View>
  </GestureHandlerRootView>
);

Props

PropsTypeRequiredDescription
valuebooleantrueCurrent state of the component
onValueChange(value: boolean) => voidtrueChange of component state
disabledbooleanfalseInactive state of the component
activeColorstringfalseContainer color when component is active
inactiveColorstringfalseContainer color when component is inactive
disabledActiveColorstringfalseContainer color when component is active and disabled
disabledInactiveColorstringfalseContainer color when component is inactive and disabled
shouldCancelWhenOutsidebooleanfalseShould a swipe handler be end if your finger is outside the component. Default false
containerStyleStyleProp<ViewStyle>falseSwitch container style
circleStyleStyleProp<ViewStyle>falseSwitch circle style
trackWidthnumberfalseThe width that the circle will be able to move. Default formula is 'containerWidth - circleWidth - containerPaddingHorizontal * 2'

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library