Skip to content

Repository files navigation

react-toggle-switch

A simple iOS inspired toggle switch.

Switch

Install

npm install --save react-toggle-switch

Usage

importReactfrom'react';import{render}from'react-dom';importSwitchfrom'react-toggle-switch'exportdefaultclassMyComponentextendsReact.Component{render(){return(<div><SwitchonClick={()=>this.setState({prop: !this.state.prop})}/><SwitchonClick={this.toggle}><iclass="some-icon"/></Switch><Switchenabled={false}/><SwitchclassName='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

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages