🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

react-segmented-control

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-segmented-control

Simple react.js component for a segmented control

Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
13
-7.14%
Maintainers
2
Weekly downloads
 
Created
Source

react-segmented-control

Simple React component for a segmented control.

Demo

Demo

Install

npm install react-segmented-control --save

or

bower install react-segmented-control --save

Example

Controlled usage:

var SegmentedControl = require('react-segmented-control');

var App = React.createClass({

  getInitialState() {
    return {
      color: 'red'
    };
  },
  render() {
    return (
      <div>
        <SegmentedControl 
          onChange={this.colorUpdated} 
          value={this.state.color}
          name="color">
          <span value="red">Red</span>
          <span value="blue">Blue</span>
        </SegmentedControl>
        <div className='background' style={{background: this.state.color}} />
      </div>
    );
  },
  
  colorUpdated(value) {
    this.setState({color: value});
  }
});

API

Props

All props are optional except name.

className

Class of the Component (in addition of segmented-control).

onChange

Function called when the control is changed (value will be passed as an argument).

defaultValue or value

Use defaultValue to specify an initial value. Use value to use this component as a controlled component.

name

Name of the input.

Styles

Look at react-segmented-control.css for an idea on how to style this component.

MIT Licensed

Keywords

react

FAQs

Package last updated on 04 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts