Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/trendmicro-frontend/react-toggle-switch

React Toggle Switch component
https://github.com/trendmicro-frontend/react-toggle-switch

Last synced: 11 days ago
JSON representation

React Toggle Switch component

Awesome Lists containing this project

README

        

# react-toggle-switch [![build status](https://travis-ci.org/trendmicro-frontend/react-toggle-switch.svg?branch=master)](https://travis-ci.org/trendmicro-frontend/react-toggle-switch) [![Coverage Status](https://coveralls.io/repos/github/trendmicro-frontend/react-toggle-switch/badge.svg?branch=master)](https://coveralls.io/github/trendmicro-frontend/react-toggle-switch?branch=master)

[![NPM](https://nodei.co/npm/@trendmicro/react-toggle-switch.png?downloads=true&stars=true)](https://nodei.co/npm/@trendmicro/react-toggle-switch/)

React Toggle Switch

Demo: https://trendmicro-frontend.github.io/react-toggle-switch

## Installation

1. Install the latest version of [react](https://github.com/facebook/react) and [react-toggle-switch](https://github.com/trendmicro-frontend/react-toggle-switch):

```
npm install --save react @trendmicro/react-toggle-switch
```

2. At this point you can import `@trendmicro/react-toggle-switch` and its styles in your application as follows:

```js
import ToggleSwitch from '@trendmicro/react-toggle-switch';

// Be sure to include styles at some point, probably during your bootstraping
import '@trendmicro/react-toggle-switch/dist/react-toggle-switch.css';
```

## Usage

### Uncontrolled Component

```js
{
this.toggleSwitch = node;
}}
/>
```

You can get the value of the checked attribute:

```js
console.log(this.toggleSwitch.checked);
// => true
```

### Controlled Component

```js
{
this.setState({ checked: !this.state.checked });
}}
/>
```

## API

### Properties



Name
Type
Default
Description




checked
boolean
false



disabled
boolean
false



onChange
function

A callback fired when toggling checked state.


size
One of:
'large'
'lg'
'small'
'sm'
'lg'


## License

MIT