1.1.1 • Published 6 years ago
use-react-switch v1.1.1
😻 use-react-switch
Install 😎
npm install --save use-react-switchUsage 🤔
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 👇

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