1.0.0 • Published 4 years ago

toggle-switch-react v1.0.0

Weekly downloads
25
License
MIT
Repository
github
Last release
4 years ago

Toggle Switch Component for react native, it works on iOS and Android.

Content

Installation

  • 1.Run npm i toggle-switch-rn --save
  • 2.import ToggleSwitch from 'toggle-switch-rn'

Demo

Screenshots

Getting started

To Get Started, Import toggle-switch-rn to your js file.

import ToggleSwitch from 'toggle-switch-rn'

Inside your component's render method, or any other method returning views, use ToggleSwitch:

<ToggleSwitch
  isOn={false}
  onColor="green"
  offColor="red"
  label="Example label"
  labelStyle={{ color: "black", fontWeight: "900" }}
  size="large"
  onToggle={isOn => console.log("changed to : ", isOn)}
/>

API

PropsTypeOptionalDefaultDescription
isOnBooleantrue'false'Default state, true for On, false for off
onColorStringtrue'#634fc9'On Color
offColorStringtrue'#ecf0f1'Off Color
labelStringtrueCustom Label Text on the Left of the toggle Button
labelStyleObjecttrue{marginHorizontal: 10}Custom Styling for the Label Text View
sizeStringtrue'medium'Size of the toggle switch button ( 'large', 'medium', 'small')
iconReact ComponenttruenullIcon for the toggle. Can be any React Component considerate of size
onToggleFunction CallbackfalsenoneCallback when the toggle switch component changes the state, params: isOn
disabledBooleantrue'false'Disable toggling the component

Contribution

If you encountered an Issue, please add a screenshot of the bug or a code snippet.

Quickest way to solve issue is to reproduce it on the example project

Pull requests are welcome. If you want to change the API or imporove something, feel free to create an issue and discuss it first.


MIT Licensed