+
Skip to content

tinglejs/tingle-on-off

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tingle-on-off npm version

Radio Component, iPhone style.

Install

npm install tingle-on-off --save

Usage

class Demo extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            on1: true,
            on2: false,
            on3: false
        }
    }

    handleChange(form, on) {
        this.setState({
            [form]: on
        });
    }

    render() {
        return (
            <div>
                <OnOff on={this.state.on1} onChange={this.handleChange.bind(this, "on1")}/>
                <OnOff on={this.state.on2} onChange={this.handleChange.bind(this, "on2")}/>
                <OnOff on={this.state.on3} readOnly={true} onChange={this.handleChange.bind(this, "on3")}/>
            </div>
        );
    }
}

Options

  • className:(default ``) Defines className that you can add to the component.
  • on:(default true) Defines whether the component should be on.
  • readOnly:(default false) Defines whether the component is readOnly(can not be modified by user action).
  • onChange:(default function(on,e){}) Defines callback whenever the component value changed.
    • on The on state after change.
    • event The SyntheticEvent object.

Links

About

The `OnOff Component` for tinglejs

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载