npm install --save use-react-switchimport 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 | 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 |
This is how it looks but if you looking for something live click here 👇
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/
MIT © shahabvshahabi1996
