Giter VIP home page Giter VIP logo

toggle-switch-react-native's Introduction

Toggle Switch Component for react native, it works on Android, iOS and Web (react-native-web).

Buy Me A Coffee

Content

Installation

    1. Run npm i toggle-switch-react-native --save
    1. import ToggleSwitch from 'toggle-switch-react-native'

Demo

Screenshots

Getting started

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

import ToggleSwitch from 'toggle-switch-react-native'

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

Props Type Optional Default Description
isOn Boolean true 'false' Default state, true for On, false for off
onColor String true '#634fc9' On Color
offColor String true '#ecf0f1' Off Color
label String true Custom Label Text on the Left of the toggle Button
labelStyle Object, StyleSheet true {marginHorizontal: 10} Custom Styling for the Label Text View
thumbOnStyle Object, StyleSheet true null Custom Styling for the On Thumb
thumbOffStyle Object, StyleSheet true null Custom Styling for the Off Thumb
trackOnStyle Object, StyleSheet true null Custom Styling for the On Track
trackOffStyle Object, StyleSheet true null Custom Styling for the Off Track
size String true 'medium' Size of the toggle switch button ( 'large', 'medium', 'small')
icon React Component true null Icon for the toggle. Can be any React Component considerate of size
onToggle Function Callback false none Callback when the toggle switch component changes the state, params: isOn
disabled Boolean true 'false' Disable toggling the component
animationSpeed Number true 300 Speed of the toggle animation

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

toggle-switch-react-native's People

Contributors

aminebenkeroum avatar dependabot[bot] avatar og24715 avatar proserve avatar maxs555 avatar g3z avatar pruthvip avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.