Radio Component, iPhone style.
npm install tingle-on-off --save
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>
);
}
}
className
:(default ``) Defines className that you can add to the component.on
:(defaulttrue
) Defines whether the component should be on.readOnly
:(defaultfalse
) Defines whether the component is readOnly(can not be modified by user action).onChange
:(defaultfunction(on,e){}
) Defines callback whenever the component value changed.on
The on state after change.event
TheSyntheticEvent
object.