# checkbox-list-react

> >

Latest version **1.0.3** (published 2019-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install checkbox-list-react
pnpm add checkbox-list-react
yarn add checkbox-list-react
bun add checkbox-list-react
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-02-05 |
| First published | 2019-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 31 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | puribey |
| Maintainers | puribey |

## Links

- npm: https://www.npmjs.com/package/checkbox-list-react
- Repository: https://github.com/puribey/react-checkboxes
- Homepage: https://github.com/puribey/react-checkboxes#readme
- Issues: https://github.com/puribey/react-checkboxes/issues
- npm.io page: https://npm.io/package/checkbox-list-react

## Dependencies (1)

- [classnames](https://npm.io/package/classnames.md) ^2.2.6

## Recent versions

- 1.0.3 (latest) — 2019-02-05
- 1.0.2 — 2019-02-05
- 1.0.1 — 2019-02-05
- 1.0.0 — 2019-02-05

## README

# checkbox-list-react

> 

[![NPM](https://img.shields.io/npm/v/react-checkboxes.svg)](https://www.npmjs.com/package/react-checkboxes) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Implementation
1. Install
```
npm install --save checkbox-list-react
```

2. Import
```
import CheckBoxes from 'checkbox-list-react'
```

3. Data input
```
list = []
```
```
inputs = {
  lunch: 'Almuerzo',
  breakfast: 'Desayuno',
  snack: 'Merienda',
  dinner: 'Cena',
  foodBag: 'Bolsa de alimentos'
}
```

4. Example Usage

```
export default class CheckboxContainer extends Component {
  constructor () {
    super()

    this.state = {
        data: {

        }
    }
  }

  onChange = e => {
    const { data } = this.state

    this.setState({
      data: {
        ...data,
        [e.target.name]: e.target.value
      }
    })
  }

  render() {
    return(
      <div>
        <CheckBoxes list={list} inputs={inputs} onChange={this.onChange} name="food"/>
      </div>
    )
  }
}
```
5. What should be rendered 

- [ ] Almuerzo
- [ ] Desayuno
- [ ] Merienda
- [ ] Cena
- [ ] Bolsa de alimentos

6. Output when checked

- [x] Almuerzo
- [x] Desayuno
- [ ] Merienda
- [ ] Cena
- [ ] Bolsa de alimentos

```
e.target.value = ['lunch', 'breakfast']
```

## Optional styling
![image](StyledCheckBoxes.png)
```
.custom-checkbox {
  font-family: 'Open Sans', sans-serif;
  font-weight: 600;
  display: block;
  position: relative;
  padding-left: 30px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 14px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 20px;
  width: 20px;
  border: 2px solid #76838f;
  background-color: transparent;
}

.custom-checkbox input:checked ~ .checkmark {
  background-color: #2196f3;
}

.custom-checkbox:after {
  content: '';
  position: absolute;
  display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
  display: block;
}

.custom-checkbox .checkmark:after {
  content: '';
  position: relative;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
  display: none;
}

```

## License

MIT © [puribey](https://github.com/puribey)

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