You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
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

A simple and elegant checkbox tree for React.

1.8.0
latest
Source
npmnpm
Version published
Weekly downloads
160K
-16.88%
Maintainers
1
Weekly downloads
 
Created

What is react-checkbox-tree?

The react-checkbox-tree package is a React component for displaying hierarchical checkbox trees. It allows users to select multiple items from a tree structure, with support for checking/unchecking nodes, expanding/collapsing branches, and more.

What are react-checkbox-tree's main functionalities?

Basic Checkbox Tree

This feature allows you to create a basic checkbox tree with nodes and children. The code sample demonstrates how to set up a tree with a parent node 'Mars' and two child nodes 'Phobos' and 'Deimos'. The 'Phobos' node is checked by default, and the 'Mars' node is expanded.

<CheckboxTree
  nodes={[
    {
      value: 'mars',
      label: 'Mars',
      children: [
        { value: 'phobos', label: 'Phobos' },
        { value: 'deimos', label: 'Deimos' }
      ]
    }
  ]}
  checked={['phobos']}
  expanded={['mars']}
  onCheck={(checked) => this.setState({ checked })}
  onExpand={(expanded) => this.setState({ expanded })}
/>

Custom Icons

This feature allows customization of the icons used in the checkbox tree. The code sample shows how to replace the default icons with custom ones by providing a set of custom icon components.

<CheckboxTree
  nodes={nodes}
  checked={checked}
  expanded={expanded}
  onCheck={this.onCheck}
  onExpand={this.onExpand}
  icons={{
    check: <span className="rct-icon rct-icon-check" />,
    uncheck: <span className="rct-icon rct-icon-uncheck" />,
    halfCheck: <span className="rct-icon rct-icon-half-check" />,
    expandClose: <span className="rct-icon rct-icon-expand-close" />,
    expandOpen: <span className="rct-icon rct-icon-expand-open" />,
    expandAll: <span className="rct-icon rct-icon-expand-all" />,
    collapseAll: <span className="rct-icon rct-icon-collapse-all" />,
    parentClose: <span className="rct-icon rct-icon-parent-close" />,
    parentOpen: <span className="rct-icon rct-icon-parent-open" />,
    leaf: <span className="rct-icon rct-icon-leaf" />
  }}
/>

Disabled Nodes

This feature allows you to disable specific nodes in the tree, preventing them from being checked or unchecked. The code sample demonstrates how to disable the 'Phobos' node.

<CheckboxTree
  nodes={[
    {
      value: 'mars',
      label: 'Mars',
      children: [
        { value: 'phobos', label: 'Phobos', disabled: true },
        { value: 'deimos', label: 'Deimos' }
      ]
    }
  ]}
  checked={[]}
  expanded={['mars']}
  onCheck={(checked) => this.setState({ checked })}
  onExpand={(expanded) => this.setState({ expanded })}
/>

Other packages similar to react-checkbox-tree

Keywords

react

FAQs

Package last updated on 06 Sep 2022

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