@s-ui/react-organism-nested-checkboxes
Version:
This component shows a parent checkbox with children that their controls his own state.
62 lines (50 loc) • 2.57 kB
Markdown
# OrganismNestedCheckboxes
This component shows a parent checkbox with children that their controls his own state.
[](https://sui-components.vercel.app/workbench/organism/nestedCheckboxes/)
[](https://github.com/SUI-Components/sui-components/issues/new?&projects=4&template=bug-report.yml&assignees=&template=report-a-bug.yml&title=🪲+&labels=bug,component,organism,nestedCheckboxes)
[](https://www.npmjs.com/package/@s-ui/react-organism-nested-checkboxes)
[](https://github.com/SUI-Components/sui-components/issues?q=is%3Aopen+label%3Acomponent+label%3AnestedCheckboxes)
[](https://github.com/SUI-Components/sui-components/blob/main/components/organism/nestedCheckboxes/LICENSE.md)
## Installation
```sh
$ npm install @s-ui/react-organism-nested-checkboxes
```
## Usage
### Basic usage
```js
import OrganismNestedCheckboxes from '@s-ui/react-organism-nested-checkboxes'
import MoleculeCheckboxField from '@s-ui/react-molecule-checkboxField'
const data = [
{id: 'nested-01', label: 'Nested 1', checked: true},
{id: 'nested-02', label: 'Nested 2', checked: true},
{id: 'nested-03', label: 'Nested 3', checked: true},
{id: 'nested-04', label: 'Nested 4', checked: false},
{id: 'nested-05', label: 'Nested 5', checked: false}
]
<OrganismNestedCheckboxes
fullCheckedStyledIcon={IconCheck}
halfCheckedStyledIcon={IconHalfCheck}
id="nested"
labelParent="Nested checkboxes"
onChangeItem={handleChangeItem}
onChangeParent={handleChangeParent}
>
{
data.map(item => {
const {id: childId, checked} = item
return (
<MoleculeCheckboxField
key={childId}
id={childId}
checked={checked}
checkedIcon={IconCheck}
intermediateIcon={IconHalfCheck}
onChange={handleChangeItem}
{...item}
/>
)
})
}
</OrganismNestedCheckboxes>
```
> **Find full description and more examples in the [demo page](https://sui-components.now.sh/workbench/organism/nestedCheckboxes/demo).**