An open API service indexing awesome lists of open source software.

https://github.com/ziad-saab/react-checkbox-group

Sensible checkbox groups manipulation for DOM.
https://github.com/ziad-saab/react-checkbox-group

checkbox javascript react

Last synced: about 1 year ago
JSON representation

Sensible checkbox groups manipulation for DOM.

Awesome Lists containing this project

README

          

# [React](http://facebook.github.io/react/)-checkbox-group

[![Greenkeeper badge](https://badges.greenkeeper.io/ziad-saab/react-checkbox-group.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/ziad-saab/react-checkbox-group.svg?branch=master)](https://travis-ci.org/ziad-saab/react-checkbox-group)

This is your average checkbox group:

```html

Apple
Orange
Watermelon

```

Repetitive, hard to manipulate and easily desynchronized.
Lift up `name` and `onChange`, and give the group an initial checked values array.
See below for a [complete example](#example)

## Install

```sh
npm install react-checkbox-group
```

or

```sh
yarn add react-checkbox-group
```

Simply require/import it to use it:

```tsx
import CheckboxGroup from 'react-checkbox-group'
```

## Example

```tsx
import React, { useState, useEffect } from 'react'
import CheckboxGroup from 'react-checkbox-group'

const Demo = () => {
// Initialize the checked values
const [fruits, setFruits] = useState(['apple', 'watermelon'])

useEffect(() => {
const timer = setTimeout(() => {
setFruits(['apple', 'orange'])
}, 5000)

return () => clearTimeout(timer)
}, [])

return (

{(Checkbox) => (
<>

Apple


Orange


Watermelon

>
)}

)
}

ReactDOM.render(, document.body)
```

## License

MIT.