Package Exports
- react-checkbox-tree
- react-checkbox-tree/lib/react-checkbox-tree.css
- react-checkbox-tree/src/less/react-checkbox-tree.less
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-checkbox-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-checkbox-tree
A simple and elegant checkbox tree for React.

Usage
Installation
Install the library using your favorite dependency manager:
yarn add react-checkbox-treeUsing npm:
npm install react-checkbox-tree --saveNote – This library makes use of Font Awesome styles and expects them to be loaded in the browser.
Include CSS
For your convenience, the library's styles can be consumed utilizing one of the following files:
node_modules/react-checkbox-tree/lib/react-checkbox-tree.cssnode_modules/react-checkbox-tree/src/less/react-checkbox-tree.lessnode_modules/react-checkbox-tree/src/scss/react-checkbox-tree.scss
Either include one of these files in your stylesheets or utilize a CSS loader:
import 'react-checkbox-tree/lib/react-checkbox-tree.css';Render Component
A quick usage example is included below. Note that the react-checkbox-tree component is controlled. In other words, it is stateless. You must update its checked and expanded properties whenever a change occurs.
import React from 'react';
import CheckboxTree from 'react-checkbox-tree';
const nodes = [{
value: 'mars',
label: 'Mars',
children: [
{ value: 'phobos', label: 'Phobos' },
{ value: 'deimos', label: 'Deimos' },
],
}];
class Widget extends React.Component {
constructor() {
super();
this.state = {
checked: [],
expanded: [],
};
}
render() {
return (
<CheckboxTree
nodes={nodes}
checked={this.state.checked}
expanded={this.state.expanded}
onCheck={checked => this.setState({ checked })}
onExpand={expanded => this.setState({ expanded })}
/>
);
}
}Properties
| Property | Type | Description | Default |
|---|---|---|---|
nodes |
array | Required. Specifies the tree nodes and their children. | |
checked |
array | An array of checked node values. | [] |
expanded |
array | An array of expanded node values. | [] |
onCheck |
function | onCheck handler: function(checked) {} |
() => {} |
onExpand |
function | onExpand handler: function(expanded) {} |
() => {} |
name |
string | Optional name for the hidden <input> element. |
undefined |
nameAsArray |
bool | If true, the hidden <input> will encode its values as an array rather than a joined string. |
false |
optimisticToggle |
bool | If true, toggling a partially-checked node will select all children. If false, it will deselect. | true |
Node Properties
Individual nodes within the nodes property can have the following structure:
| Property | Type | Description |
|---|---|---|
label |
string | Required. The node's label. |
value |
mixed | Required. The node's value. |
children |
array | An array of child nodes. |
icon |
mixed | A custom icon for the node. |