Skip to content

danteoh/react-toggle-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 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 Switch from 'react-toggle-switch'

export default class MyComponent extends React.Component {
  toggle(value) {
    // do something with value
  }

  render() {
    return (
        <div>
            <Switch value={'some string or integer value'} on={true} onClick={this.toggle}/>
            <Switch onClick={() => this.setState({prop: !this.state.prop})}/>
            <Switch onClick={this.toggle}>
              <i class="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

License

Stars

Watchers

Forks

Packages

No packages published