React component, on-off sliding button to keep track of a user choice or state.
Click or drag to change state, no extra CSS file(s).
npm install react-onoff-switch
Simple demo example here.
import OnOff from 'react-onoff-switch'
ReactDOM.render(
<OnOff onChange={(value) => console.log('New value is:', value)}/>,
document.getElementById('app')
);
name | type | default | description |
---|---|---|---|
initialValue | Boolean | false | The initial state |
onChange | Function | Change callback, receives current value as argument | |
width | Number | 100 | Component size, will be used as pixels |
buttonColor | Stringe | '#FFFFFF' (white) | Button color |
passiveColor | Stringe | '#FFFFFF' (white) | Passive background color |
activeColor | Stringe | '#13BF11' (green) | Active background color |