react-native-dark-mode-switcher
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

React Native Dark Mode Switcher

React Native Dark Mode Switcher

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

React Native Dark Mode Switcher

Installation

Add the dependency:

npm i react-native-dark-mode-switcher

Peer Dependencies

No Dependencies

Usage

Import

import DarkModeSwitcher from "react-native-dark-mode-switcher";

Fundamental Usage

<DarkModeSwitcher
  value={switchValue}
  onChange={() => {
    setSwitchValue((previousState: boolean) => !previousState);
  }}
/>

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

Property Type Default Description
value boolean true set the value of the switch
onChange function undefined set your own function for when the switch value is changed

Customization (Optionals)

Property Type Default Description
style ViewStyle default set/override the style object for the outer container
containerStyle ViewStyle default set/override the style object for the container
moonStyle ViewStyle default set/override the style object for the moon style
knobStyle ViewStyle default set/override the style object for the knob style
activeColor color "#fff" change the active background color of switch
inactiveColor color "#000" change the inactive background color of switch
size number 100 change the size of the switch
animationDuration number 200 change the animation duration
animationEasing Easing Easing.linear change the animation easing type

Future Plans

  • [x] LICENSE
  • [ ] Write an article about the lib on Medium

Credits

Heavily inspired by Vijaydemonz's React Native Animated Switch NPM

Author

FreakyCoder, kurayogun@gmail.com

License

React Native Dark Mode Switcher is available under the MIT license. See the LICENSE file for more info.

Package Sidebar

Install

npm i react-native-dark-mode-switcher

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

110 kB

Total Files

21

Last publish

Collaborators

  • freakycoder