use-react-switch

1.1.1 • Public • Published

😻 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

Readme

Keywords

none

Package Sidebar

Install

npm i use-react-switch

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

20.1 kB

Total Files

6

Last publish

Collaborators

  • shahabvshahabi1996