Skip to content

msrikanth508/react-ui-toggler

Repository files navigation

License: MIT Build Status Coverage Status

A simple and effective react toggle component.

webp net-gifmaker 2

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

import "react-ui-toggler/dist/react-ui-toggler.min.css" // for ES6 modules
// or
require("react-ui-toggler/dist/react-ui-toggler.min.css") // for CommonJS

Development

npm install
npm start

Test

npm test

Build

npm run build

License

MIT