Socket
Socket
Sign inDemoInstall

react-checkbox-tree

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-checkbox-tree

React component for checkbox trees.


Version published
Weekly downloads
87K
decreased by-2.84%
Maintainers
1
Weekly downloads
 
Created
Source

react-checkbox-tree

npm Dependency Status devDependency Status GitHub license

Checkbox treeview for React.

Demo

Installation

The easiest way to use react-checkbox-tree is to install from NPM and include it in your own React build process (e.g. using Webpack):

npm install react-checkbox-tree --save

Note – This library requires that Font Awesome styles are loaded in the browser.

Usage

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 CheckboxTree from 'react-checkbox-tree';

const nodes = [{
    value: 'node-1',
    title: 'Parent Node 1',
    children: [{
        value: 'node-1-1',
        title: 'Leaf Node 1-1',
    }, {
        value: 'node-1-2',
        title: 'Leaf Node 1-2'
    }],
}];

class Widget extends React.Component {
    constructor() {
        super();

        this.state = {
            checked: [],
            expanded: [],
        };
    }

    render() {
        const { checked, expanded } = this.state;

        return (
            <Tree
                name="tree_nodes"
                nodes={nodes}
                checked={checked}
                expanded={expanded}
                onCheck={checked => this.setState({ checked }}
                onExpand={expanded => this.setState({ expanded }}
            />
        );
    }
}

Properties

PropertyTypeDescriptionDefault
checkedarrayRequired. An array of checked node values.
expandedarrayRequired. An array of expanded node values.
nodesarrayRequired. Specifies the tree nodes and their children.
onCheckfunctionRequired. onCheck handler: function(checked) {}
onExpandfunctionRequired. onExpand handler: function(expanded) {}
namestringOptional name for the hidden <input> element.undefined
nameAsArrayboolIf true, the hidden <input> will encode its values as an array rather than a joined string.false
optimisticToggleboolIf true, toggling a partially-checked node will select all children. If false, it will deselect.true

Keywords

FAQs

Package last updated on 27 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc