npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-custom-switch

v1.0.7

Published

A fully customizable switch component for react native.

Downloads

5,918

Readme

React-Native-Custom-Switch

A lightweight, fully customizable switch component for React Native.

ezgif com-gif-maker (1)

Installation

npm install react-native-custom-switch

Usage

import CustomSwitch from 'react-native-custom-switch';
<CustomSwitch />

Basic Usage

ezgif com-gif-maker (2)

Provide a callback function to onSwitch() which will be called when the switch is pressed.

<CustomSwitch 
  onSwitch={() => changeToDarkTheme()>
/>

Flexible Sizing

ezgif com-gif-maker (3)

<CustomSwitch 
  onSwitch={() => sayHello()>
  buttonWidth={20}
  switchWidth={100}
  buttonPadding={2}
/>

Customizable Colors

ezgif com-gif-maker (4)

<CustomSwitch 
  buttonColor={'#EFE6DD'}
  switchBorderColor={'#F3DFA2'}
  buttonBorderColor={'#997048'}
  switchBackgroundColor={'#7EBDC2'}
  onSwitchBackgroundColor={'#BB4430'}
/>

Add background Text, and customize the style

ezgif com-gif-maker (5)

<CustomSwitch 
  switchLeftText={"Tea"}
  switchLeftTextStyle={{color: 'green', fontSize: 24}}
  switchRightText={"Coffee"}
  switchRightTextStyle={{color: 'brown', fontSize: 24}}
/>

Add text to the button

ezgif com-gif-maker (7)

<CustomSwitch 
  buttonText={'Hello'}
  onSwitchButtonText={'Bye'}
/>

...including Emojis

ezgif com-gif-maker (6)

<CustomSwitch 
  switchLeftText={"☀️"}
  switchRightText={"🌙"}
/>

Props | Description | Example | Default | --- | --- | --- | --- | buttonWidth | Adjusts the width of the button. | buttonWidth={20} | 20 | buttonPadding | Adjusts the amount of padding around the button. | buttonPadding={5} | undefined | buttonColor | Adjusts the color of the button. | buttonColor={'#FFFFFF'} | #FFFFFF | buttonBorderWidth | Adjusts the width of the button border. | buttonBorderWidthbuttonBorderWidth={1} | undefined | buttonBorderColor | Adjusts the color of the button border. | buttonBorderColor={'#D4EDE1'} | undefined | buttonText | Defines the text that will appear inside of the button. | buttonText={"On"} | undefined | buttonTextStyle | Adjusts the style of the text inside of the button. | buttonTextStyle={{fontSize: 18}} | undefined | switchWidth | Adjust the total width of the switch. | switchWidth={75} | 50 | switchBackgroundColor | Adjusts the background color of the switch. | switchBackgroundColor={'#0f2832'} | #D4EDE1 | switchBorderWidth | Adjusts the width of the switch border. | switchBorderWidth={2} | undefined | switchBorderColor | Adjusts the color of the switch border. | switchBorderColor={'#0f2832'} | undefined | switchLeftText | Defines the text that appears on the left side of the switch. | switchLeftText={'On'} | undefined | switchLeftTextStyle | Adjusts the style of the text on the left side of the switch. | switchLeftTextStyle={{fontSize: 18}} | undefined | switchRightText | Defines the text that appears on the right side of the switch | switchRightText={'Off} | undefined | switchRightTextStyle | Adjusts the style of the text on the right side of the switch. | switchRightTextStyle={{fontSize: 18}} |undefined | onSwitch | Takes a callback that is called when the switch is pressed. | onSwitch={() => changeTheme} | undefined | onSwitchReverse | Takes a callback that is called when the switch position is reversed. | onSwitchReverse={() => sayHello()} | undefined | onSwitchButtonText | Defines the text that will appear in the button when the switch is pressed. | onSwitchButtonText | undefined | onSwitchButtonTextStyle | Adjusts the style of the text in the button when the switch is pressed. | onSwitchButtonTextStyle={{fontSize: 18}} |undefined | onSwitchBackgroundColor | Adjusts the background color of the switch when the switch is pressed. | onSwitchBackgroundColor={'#0f2832'} | undefined | animationSpeed | Adjuts the speed of the animation when the switch is pressed. | animationSpeed={50} | 150 | startOnLeft | Changes the start position of the switch to the right side. | startOnLeft={true} | false | disabled | Prevents the switch from being pressed. | disabled={true} | false |