
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
checkbox-tree-react
Advanced tools
Creates a tree structure for you from your custom data. Uses react and bootstrap.
react-checkbox-tree
Hi! I am a software developer and made this package to simplify life for some developers seeking similar solution for their react projects. This package let's you create a simple but custom checkbox tree from any data type you have, and implement it in your react project with a simple component.
It is as simple as it looks like:
npm install react-checkbox-tree
This project depends on fontawesome
and react
.
You will need to do two steps first in order to get ready to use your data in the checkbox tree.
First, get your data prepared:
const data = [
{ // These are your main root nodes
'id': 1,
'name': 'Group A',
'subGroups': [
{ // These are the children of the main nodes
'id': 1,
'name': 'Sub group 1',
'leaves': [
{ // These are leaves without nodes
'id': 1,
'name': 'Mark'
},
//...
]
},
//...
]
},
//...
]
This part of code above creates a simple tree with one root node, that has one childand that child has one leaf.
The accessor has a structure like this:
{
label: '**enter the name of the field in your data element to display in the tree node**',
value: '**enter the name of the value field for the node**',
type: '**this is used to group your selection of checkboxes by tree levels**',
leaves: '**this is a name of the field to get children for this node**'
}
Now you have to make accessors to each branch level in your data, so that the tree knows how to access your data. This can be done as follows for the above example:
const accessors = [
{
label: 'name',
value: 'id',
leaves: 'subGroups',
type: 'root'
},
{
label: 'name',
value: 'id',
leaves: 'leaves',
type: 'group'
},
{
label: 'name',
value: 'id',
type: 'leaf'
}
]
Now you can use the tree element and add it to your view, notice that you are passing the data
and accessors
variables into the component:
<CheckboxTree data={data} accessors={accessors} />
The CheckboxTree element can also have onChange
parameter that accepts a method(items)
as value.
A main element that holds the tree of checkboxes from the data that is build with accessors.
MIT
FAQs
[](https://badge.fury.io/js/checkbox-tree-react) [](https://coveralls.io/github/M
We found that checkbox-tree-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.