A simple and effective react toggle component.
Props
The component takes the following props.
Prop | Type | Default | Description |
---|---|---|---|
disabled | boolean | fasle |
If true , the toggler is disabled. If false , the toggler is enabled. |
isActive | boolean | false |
If true , the toggler is checked. If false , the toggler is unchecked. |
offLabel | string | You can pass any string to be shown when toggler is off. | |
onChange | function | Callback function to invoke when the user clicks on the toggler. The function signature should be the following: const func = (e, isActive) => { } . Function returns event and toggler status whether it's active or not. |
|
onLabel | string | You can pass any string to be shown when toggler is on. |
Examples
Find more examples here
Installation
npm install react-ui-toggler --save
Usage
Include the component's CSS with
// or // for CommonJS
Development
npm installnpm start
Test
npm test
Build
npm run build
License
MIT