# react-segmented-control

> Simple react.js component for a segmented control

Latest version **0.2.2** (published 2016-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-segmented-control
pnpm add react-segmented-control
yarn add react-segmented-control
bun add react-segmented-control
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2016-09-16 |
| First published | 2015-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Mathieu Dutour |
| Maintainers | enkilabs, mathieudutour |
| Keywords | react, segmented, control, component, javascript, react-component |

## Links

- npm: https://www.npmjs.com/package/react-segmented-control
- Repository: https://github.com/enki-com/react-segmented-control
- Issues: https://github.com/enki-com/react-segmented-control/issues
- npm.io page: https://npm.io/package/react-segmented-control

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2016-09-16
- 0.2.1 — 2015-12-04
- 0.2.0 — 2015-12-03
- 0.1.0 — 2015-05-27

## README

# react-segmented-control

> Simple [React](http://facebook.github.io/react/index.html) component for a segmented control.

### [Demo](https://enki-com.github.io/react-segmented-control)

[![Demo](https://cdn.rawgit.com/enki-com/react-segmented-control/master/example/demo.gif "Demo")](https://github.com/enki-com/react-segmented-control/blob/master/example/index.html)

## Install

```bash
npm install react-segmented-control --save
```

or

```bash
bower install react-segmented-control --save
```

## Example

Controlled usage:

```javascript
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](https://github.com/enki-com/react-segmented-control/blob/master/react-segmented-control.css) for an idea on how to style this component.

---

MIT Licensed

---
_Source: https://npm.io/package/react-segmented-control · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
