Skip to content

cjpete/react-toggle-switch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-toggle-switch

A simple iOS inspired toggle switch.

Switch

Install

npm install --save react-toggle-switch

Usage

import React from 'react';
import {render} from 'react-dom';
import Switch from 'react-toggle-switch'

export default class MyComponent extends React.Component {
  render() {
    return (
        <div>
            <Switch onClick={() => this.setState({prop: !this.state.prop})}/>
            <Switch onClick={this.toggle}>
              <i class="some-icon"/>
            </Switch>
            <Switch enabled={false}/>
            <Switch className='other-class'/>
        </div>
    );
  }
}

Props

  1. onClick - Function handler to be called any time the switch is clicked.
  2. on - Sets the switch on or off. This can be useful if you want to update the state of the switch without actually clicking on it. Default is false.
  3. enabled - If set to false, the switch cannot be toggled. Default is true.
  4. className - An optional classname for the root element

Import Styling

@import "node_modules/react-toggle-switch/dist/css/switch.min.css"

About

iOS inspired toggle switch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 73.9%
  • CSS 18.9%
  • HTML 7.2%