Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
76K
decreased by-6.87%
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

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

PropertyTypeDescription
nodesarrayRequired. Specifies the tree nodes and their children.
checkedarrayRequired. An array of checked node values.
expandedarrayRequired. An array of expanded node values.
onCheckfunctionRequired. onCheck handler: function(checked) {}
onExpandfunctionRequired. onExpand handler: function(expanded) {}
namestringOptional name for the hidden <input> element.
nameAsArrayboolIf true, the hidden <input> will encode its values as an array rather than a joined string.

Keywords

FAQs

Package last updated on 15 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