Skip to content

shahabvshahabi1996/use-react-switch

Repository files navigation

😻 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

Props Default Value Type Description
isOpen false Boolean Shows the status of switch (Open Or Close)
onClick ____ Function ____
name ____ String name of your swicth component for handling states
containerStyles ____ Object inline-styles for your switch container
toggleStyles ____ Object inline-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