https://github.com/wtnm/checkboxes-component
https://github.com/wtnm/checkboxes-component
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/wtnm/checkboxes-component
- Owner: wtnm
- License: mit
- Created: 2021-04-11T20:04:01.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-01T13:24:47.000Z (almost 5 years ago)
- Last Synced: 2024-10-30T06:57:02.299Z (over 1 year ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## Overview
`react-checkboxes` - component that renders several checkboxes (or radio) as single input.
## Installation
To install the stable version:
```
npm install --save react-checkboxes
```
## Usage
```
import {Checkboxes} from 'react-merge'
```
## Documentation
####Checkboxes(props: CheckboxesProps)
`CheckboxesProps` - object with following properties:
- `_$useTag: string | FunctionComponent` - tag than will be used for chexboxes, default is `Checkbox`.
- `$enum: Array` - array of possible values.
- `$staticProps: anyObject` - props that passed to every inner checkbox. `onChange` or `onClick` should be passed here.
- `$enumExten: anyObject` - extension of `$enum`, props that passed to inner checkbox individually.
- `name: string` - name for inner checkboxes.
- `type: string` - type of checkboxes (`radio` or `chexbox` for input)
- `value: any` - value
- `[key: string]: any` - rest props will be passed to the root element unchanged.
####Checkbox(props: CheckboxProps)
`CheckboxesProps` - object with following properties:
- `name: string` - name
- `type: string` - type of checkbox (`radio` or `chexbox` for input)
- `label: string` - label
- `value: any` - value
- `$extend` - Component `Checkbox` consists of 3 inner elements: `checkbox`, `input`, `label`.
Elements `input` and `label` are inner elements of `checkbox` element. Each element can be extended with custom props passed in `$extend[elementName]`.
For example, to add to `label` prop `onClick` should be like: `$extend = {label: {onClick:()=>alert('label')}}`
- `[key: string]: any` - rest props will be passed to the input element unchanged.