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';importSwitchfrom'react-toggle-switch'exportdefaultclassMyComponentextendsReact.Component{toggle(value){// do something with value}render(){return(<div><Switchvalue={'some string or integer value'}on={true}onClick={this.toggle}/><SwitchonClick={()=>this.setState({prop: !this.state.prop})}/><SwitchonClick={this.toggle}><iclass="some-icon"/></Switch></div>);}}

Props

  1. onClick - Required function handler for when the switch is clicked.
  2. value - Required value that will be passed to the onClick handler.
  3. on - Optional prop to set switch on or off. Default is false.

Import Styling

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

About

iOS inspired toggle switch

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages