1.1.1 • Published 5 years ago

use-react-switch v1.1.1

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

😻 use-react-switch

NPM JavaScript Style Guide

Install 😎

npm install --save use-react-switch

Usage 🤔

import React, { Component } from 'react'

import Switch from 'use-react-switch'

class Example extends Component {
  
  constructor() {
    super();
    this.state = {
      isOpen : false
    }
  }

  render () {
    let {isOpen} = this.state;
    return (
      <Switch
        name="switch"
        onClick={() => this.setState({isOpen : !isOpen})}
        isOpen={isOpen}
      />
    )
  }
}

Props

PropsDefault ValueTypeDescription
isOpenfalseBooleanShows the status of switch (Open Or Close)
onClick____Function____
name____Stringname of your swicth component for handling states
containerStyles____Objectinline-styles for your switch container
toggleStyles____Objectinline-styles for switch toggle

Demo 😍

This is how it looks but if you looking for something live click here 👇

use-react-switch

Or you can run it locally 🎉

First you need to clone it : git clone https://github.com/shahabvshahabi1996/use-react-switch.git

Then hit : npm start || yarn start

After that go to example directory and hit : npm start

Now you can check it out on your http://localhost:3000/

License 📃

MIT © shahabvshahabi1996