Site icon OnAirCode

React Tree View Component Examples with Code

React TreeView Component

Before directly jumping into technical topic just consider a tree. Imagine it from a structural point of view. There’s a main trunk from which several branches arise. Within a branch there could be multiple branches leading to leafs or buds. Compare this with actual information system. The leafs or buds are the information in the form of files and other resources. Meanwhile, the branches are the path to those resources like multiple folders under which the file reside. Did you see how difficult it would be if we didn’t know exact path to the resources? How many possible path are there and time consumed to visit the nodes? To ease this and using the same principle react tree view has been coined. A number of react tree library offers simple and effective react tree table view. Most JavaScript and HTML5 treeview offer multiple features making navigation easy.

Treeview is one of the most used web component. In particular, if there’s something related to document you’ll see the use of treeview and document will come almost everywhere. You can easily implement react tree view to your project. Although majority of work is done it may come with some limitation. So it can be wise to create a cool HTML5 and JavaScript treeview to overcome limitation of code from 3rd package.

Related

React Tree View UI Component and Libraries

We will see 12 examples of react tree which will cover topics like html5 treeview, react tree table and relevant libraries. Above all they have been designed with intention to improve user navigation experience in the application.

1. React Treebeard

The react treebeard example shown here consist of two sections. The first one contain folders organized in a hierarchy structure. The section on the right shows the details of the item currently on selection. Moreover, we have the option to expand or collapse the parent folder. This allows us the option to either see child folders and files under them or hide them if they are occupying a lot of space.

This react tree component is fast, efficient and data drive while also allowing multiple configuration options. They allow quick view of the selected files and folders to see if it contains the element we’re searching or get general idea.

Download from GitHub

2. React treeview

This is an easy, light and flexible treeview made with react. Light in the sense that it doesn’t contain any fancy styling but mainly focuses on functionality.

The example describes two type of treeview. The first one is uncontrolled where each node are manually opened and closed whereas second one is controlled allowing collapse all button. This button is responsible for closing all nodes currently on expansion. The result is that we see only parent nodes in the view. However, reverse operation is not possible.

Download from GitHub

3. React UI tree

The initial intent for this design was for webpage builder. The way it works is by maintaining a tree structure within the component through JS tree.

To test and run the demo first of all you need to npm and the start it. Second run localhost on your browser with /example url.

Download from GitHub

4. React Super Treeview

React super treeview comes with option to customize the components on every level. The customization include addition/removal of nodes, change in animation, asynchronous data loading etc. Talking about demo of this react tree table example first is the node without any children so on expanding shows empty. Another tree component is node with children which shows the child elements and so on as long as child elements are found. Next one is a bit interesting. The children nodes if present are loaded only after clicking on expand button by JavaScript treeview. This means they are not initially present but drawn from somewhere upon request by clicking expand button. Other react tree view components include option to check/uncheck parent and child nodes. And finally we have a node with delete option.

There’s also a key combination for selecting multiple nodes. You may think how is this any different from check/uncheck node feature just discussed right? Well you don’t have to click on individual nodes if it is in a sequence. You can press shift and click on start and end nodes and this selects all the nodes in between them.

This react tree library has implementation scope on applications with roles and permission. You can expand a role nodes and check/uncheck as per policy. Same is for the permission and if the data is too huge, they can be loaded asynchronously for better performance.

The react tree is still undergoing some improvements. Some CSS and auto launch features are among few enhancement going on.

Download from GitHub

5. Tree UI component for react

You may have seen this somewhere before ? Oh well is it in the PC you are using ? I hope you’re using windows though (*winks). This react tree table is a classic example of sidebar folder view from windows showing hierarchy of folders inside of a drive.

The react tree table supports all latest browsers including Internet Explorer 9 and above. There are some important notes on calculation optimization and asynchronous loading that you should look into while implementing.

Download from GitHub

6. React Sortable Tree

In order to move files and folders to different location what might be the possible options? First and most simple thing to pop up in the mind is the get to original location press cltr + X then go to new destination and paste the content. What if I say you can do this without going through all old and new destination? Well this react tree table comes with ability to visually change the location of the folder.

The react component allows to drag and drop the content. Before releasing the click it shows a new layout to understand the changes. You can press escape to cancel the selection or release the mouse to get new sorted hierarchy. Moreover, expand all and collapse all option allows easy operation. Also, search bar is present for easily retrieving required content. As it is compatible with all browsers it becomes a universal html5 treeview.

Demo | Source code

7. React Treeview with Material UI

You don’t need to go through the tree view for navigation of folders as this JavaScript react tree gives the option to navigate from buttons. Navigation follows next and previous nodes. This principle takes the computer mouse out of equation if every required. Similarly, small details display on the content screen. This makes getting content information easy without having to open it.

The data for nodes are presented in an array of list instead of object data structure. You have to keep few keys in mind for this purpose. This results in faster processing of the react tree table. Moreover, its the case of personal preference of author. Components inside the treeview uses ReactCSSTransitionGroup for animation purpose.

Demo | Source Code

8. React treeview Component

Author makes the use of HTML5, CSS and JavaScript for this treeview. Further, each node in the react tree view contains a key value pair. More better way to understand the components of treeview is by implementing in your project. Just extend the component to your class while use the treeview tag to render.

Download from GitHub

9. React Checkbox Tree

You will find 10 examples of react tree view each with different set of features. You can select the features individually and then combine them to achieve a set of features for react tree library.

The feature-rich react tree view firstly gives a basic example with check/uncheck option for all parent and child node. Animation includes faded parent node if all child nodes are not checked. Moreover, check mark on parent node will check mark all of its child node. Another feature includes custom icon as per file types. One of the animation involves open folder icon for expanded folders and closed folder icon for collapsed folder. Most notable feature is level wise setup for check/uncheck option. There more features to talk about that will in fact make a complete react tree library matching almost any type of html5 and JavaScript treeview requirement.

Demo | Code

10. Reactjs d3 tree component

JavaScript treeview allows dynamic addition and removal of nodes. This type of react tree view gives much clear idea of hierarchy structure. Parent and child nodes are connected with edges. Also, child of same parents are placed in same level.

CSS only provides styling of link division whereas JavaScript is responsible for rest of the behavior of this react tree library. The layout of the application makes this one a good element for application teaching data structures such as binary tree and its operation.

Code | Demo

11. Craft AI decision tree react component

While the previous JavaScript react tree library was well suited for data structure tutorial, this one would make learning discrete structure and AI much easy. Author makes the use of JavaScript inside of HTML5 for this treeview makes the entire application just depend upon its html5 page.

A number of change in its visual representation makes it distinct from other react tree view. They are caption for edges and hovering effect for each node. As a result when you hover over yes no node they show relevant information. Its one of the efficient method to get information on node without opening the node itself.

Demo | Code

12. D3 layout tree

I think we have entered into tutorial like implementation of react tree view since this layout looks like a probability tree diagram. Likewise, this enables a number of possibility to be visualized under single display.

Since it is based on connection of different nodes, it also holds the scope of some AI model. The react tree view has a comparatively large JavaScript library size with CSS dealing with path link and node appearance.

Demo | Code

13. ReactJS tree view

Another native example of react tree view which has the option to navigate along nodes with actually defining destination node. The traversal is along adjacent nodes. Author has made this clear by use of JavaScript alert in the tree view. Parent and child nodes are visually distinct from each other in terms of margin from left side. This means child nodes are relatively far from left end than their parents node.

This concludes the examples of react tree view for this article. Check out the demonstration and code for this one from the link below.

Demo | Code

Conclusion

Summarizing all the react JavaScript tree view examples discussed we can come to the conclusion that they serve the purpose of easy navigation and hierarchical information. Moreover, we have seen their implementation as teaching material in many computer science topics such as data structure, probability and so on. In other words, tree view serves as a guide for allowing user to look in to insights of application and information.

There will always be a number of files and folders for any person or organization. Maintaining them in a proper hierarchy will definitely make finding contents easy at any instant. Thus, use of tree view becomes must for applications dealing with multiple category and huge contents.

Exit mobile version