1.0.1 • Published 3 years ago

@vijaykumartaduri/react-native-animated-switch v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
3 years ago

Animated Switchs

This npm is to help react native developers animating and customizing switchs for both ios and android devices.

propsdefaulttypedescriptionreqired
Size100numbersize of switch in pixelsyes
valuefalseboolstate of switchyes
handleSwitchnullfunconChange funtion for switchyes
darkModeBgblackstring(hex color/rgb)nightmode colorno
lightModeBgwhitestring(hex color/rgb)day mode colorno
borderColororangestring(hex color/rgb)border color of switchno
borderWidthorangestring(hex color/rgb)border width of switchno
elevation5numberto add shadow to switch if neededno
knobColororangestring(hex color/rgb)knob coloryes
animationSpeedfastfast | medium | slowanimation speed of transitionno

Demo

demo

Usage example

import React, { useState } from "react";
import { View } from "react-native";
import AnimatedSwitch from "react-native-animated-switch";

export default function App() {
  const [isOn, setIsOn] = useState(false);

  const handleSwitch = () => {
    setIsOn((d) => !d);
  };
  return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <AnimatedSwitch
        size={100}
        value={isOn}
        handleSwitch={handleSwitch}
        knobColor={"orange"}
        borderColor={"orange"}
        lightModeBg={"white"}
        darkModeBg={"black"}
        borderWidth={2}
        animationSpeed={"fast"}
        elevation={10}
      />
    </View>
  );
}