react-treebeard vs react-accessible-treeview vs react-sortable-tree
React Tree View Libraries Comparison
1 Year
react-treebeardreact-accessible-treeviewreact-sortable-treeSimilar Packages:
What's React Tree View Libraries?

React tree view libraries are specialized components that allow developers to create hierarchical data structures in a user-friendly manner. They are particularly useful for displaying nested data, such as file systems, organizational charts, or any other tree-like structures. These libraries enhance accessibility, usability, and interactivity, enabling users to navigate complex data sets intuitively. Each of these libraries offers unique features that cater to different use cases, making it essential to choose the right one based on project requirements.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-treebeard96,7081,689-726 years agoMIT
react-accessible-treeview74,727319102 kB5a month agoMIT
react-sortable-tree60,4024,960-3445 years agoMIT
Feature Comparison: react-treebeard vs react-accessible-treeview vs react-sortable-tree

Accessibility

  • react-treebeard:

    React-treebeard does not prioritize accessibility features, and while it can be made accessible with additional effort, it may require more work compared to the other two options.

  • react-accessible-treeview:

    This library is built with accessibility in mind, adhering to ARIA standards. It supports keyboard navigation and provides appropriate roles and properties for screen readers, making it a great choice for applications that require compliance with accessibility guidelines.

  • react-sortable-tree:

    While it offers some accessibility features, it is not as focused on ARIA compliance as react-accessible-treeview. Developers may need to implement additional accessibility features to ensure a fully accessible experience for all users.

Drag-and-Drop Support

  • react-treebeard:

    React-treebeard does not provide built-in drag-and-drop functionality, so developers will need to implement this feature separately if required.

  • react-accessible-treeview:

    This library does not natively support drag-and-drop functionality, focusing instead on accessibility and navigation. If drag-and-drop is essential, additional implementation may be needed.

  • react-sortable-tree:

    This library excels in drag-and-drop support, allowing users to easily rearrange tree nodes. It provides a smooth user experience for managing hierarchical data, making it ideal for applications that require interactive data manipulation.

Customization

  • react-treebeard:

    React-treebeard is highly customizable, enabling developers to easily style the tree view according to their design requirements. It provides a straightforward API for theming and modifying node rendering.

  • react-accessible-treeview:

    Customization options are somewhat limited, as the focus is on maintaining accessibility standards. However, it still allows for some styling adjustments to fit within your application's design.

  • react-sortable-tree:

    This library offers a good level of customization, allowing developers to modify the appearance and behavior of tree nodes. It provides various props for styling and functionality, making it adaptable to different use cases.

Performance

  • react-treebeard:

    This library is lightweight and performs well with smaller to moderate-sized trees. However, it may require optimization techniques for larger datasets to maintain responsiveness.

  • react-accessible-treeview:

    Performance is generally good, but the focus on accessibility may introduce some overhead. It is suitable for moderate-sized trees but may require optimization for very large datasets.

  • react-sortable-tree:

    Performance is optimized for drag-and-drop interactions, making it suitable for larger datasets. However, performance may degrade with extremely large trees, so careful management of state and rendering is advised.

Learning Curve

  • react-treebeard:

    React-treebeard is easy to learn and implement, thanks to its simple API and clear documentation. Developers can quickly get up to speed and customize the tree view as needed.

  • react-accessible-treeview:

    The learning curve is moderate, especially for developers unfamiliar with accessibility standards. Understanding how to implement ARIA roles and properties may take some time.

  • react-sortable-tree:

    This library has a relatively easy learning curve, especially for developers familiar with drag-and-drop interfaces. Its API is straightforward, making it accessible for quick implementation.

How to Choose: react-treebeard vs react-accessible-treeview vs react-sortable-tree
  • react-treebeard:

    Opt for react-treebeard if you are looking for a lightweight and customizable tree view solution. This library offers a simple API and allows for easy styling and theming, making it suitable for projects where aesthetics and customization are important. It is also easy to integrate with existing applications without adding significant overhead.

  • react-accessible-treeview:

    Choose react-accessible-treeview if accessibility is a top priority for your application. This package is specifically designed to meet ARIA accessibility standards, ensuring that users with disabilities can navigate and interact with the tree view effectively. It provides keyboard navigation and screen reader support, making it suitable for applications that need to comply with accessibility guidelines.

  • react-sortable-tree:

    Select react-sortable-tree if you need a tree view that supports drag-and-drop functionality. This library allows users to reorder nodes easily, making it ideal for applications where users need to manage hierarchical data interactively. It also provides features like search and filtering, which enhance usability for larger datasets.

README for react-treebeard

react-treebeard

Build Status Coverage Status

React Tree View Component. Data-Driven, Fast, Efficient and Customisable.

Install

npm install react-treebeard --save

Example

An online example from the /example directory can be found here: Here

Quick Start

import React, {PureComponent} from 'react';
import ReactDOM from 'react-dom';
import {Treebeard} from 'react-treebeard';

const data = {
    name: 'root',
    toggled: true,
    children: [
        {
            name: 'parent',
            children: [
                { name: 'child1' },
                { name: 'child2' }
            ]
        },
        {
            name: 'loading parent',
            loading: true,
            children: []
        },
        {
            name: 'parent',
            children: [
                {
                    name: 'nested parent',
                    children: [
                        { name: 'nested child 1' },
                        { name: 'nested child 2' }
                    ]
                }
            ]
        }
    ]
};

class TreeExample extends PureComponent {
    constructor(props){
        super(props);
        this.state = {data};
    }
    
    onToggle(node, toggled){
        const {cursor, data} = this.state;
        if (cursor) {
            this.setState(() => ({cursor, active: false}));
        }
        node.active = true;
        if (node.children) { 
            node.toggled = toggled; 
        }
        this.setState(() => ({cursor: node, data: Object.assign({}, data)}));
    }
    
    render(){
        const {data} = this.state;
        return (
            <Treebeard
                data={data}
                onToggle={this.onToggle}
            />
        );
    }
}

const content = document.getElementById('content');
ReactDOM.render(<TreeExample/>, content);

If you use react-hooks you should do something like this:

import React, {useState} from 'react';
const TreeExample = () => {
    const [data, setData] = useState(data);
    const [cursor, setCursor] = useState(false);
    
    const onToggle = (node, toggled) => {
        if (cursor) {
            cursor.active = false;
        }
        node.active = true;
        if (node.children) {
            node.toggled = toggled;
        }
        setCursor(node);
        setData(Object.assign({}, data))
    }
    
    return (
       <Treebeard data={data} onToggle={onToggle}/>
    )
}

const content = document.getElementById('content');
ReactDOM.render(<TreeExample/>, content);

Prop Values

data

PropTypes.oneOfType([PropTypes.object,PropTypes.array]).isRequired

Data that drives the tree view. State-driven effects can be built by manipulating the attributes in this object. Also supports an array for multiple nodes at the root level. An example can be found in example/data.js

onToggle

PropTypes.func

Callback function when a node is toggled / clicked. Passes 2 attributes: the data node and it's toggled boolean state.

style

PropTypes.object

Sets the treeview styling. Defaults to src/themes/default.

animations

PropTypes.oneOfType([PropTypes.object, PropTypes.bool])

Sets the treeview animations. Set to false if you want to turn off animations. See velocity-react for more details. Defaults to src/themes/animations.

decorators

PropTypes.object

Decorates the treeview. Here you can use your own Container, Header, Toggle and Loading components. Defaults to src/decorators. See example below:

const decorators = {
    Loading: (props) => {
        return (
            <div style={props.style}>
                loading...
            </div>
        );
    },
    Toggle: (props) => {
        return (
            <div style={props.style}>
                <svg height={props.height} width={props.width}>
                    // Vector Toggle Here
                </svg>
            </div>
        );
    },
    Header: (props) => {
        return (
            <div style={props.style}>
                {props.node.name}
            </div>
        );
    },
    Container: (props) => {
        return (
            <div onClick={this.props.onClick}>
                // Hide Toggle When Terminal Here
                <this.props.decorators.Toggle/>
                <this.props.decorators.Header/>
            </div>
        );
    }
};

<Treebeard data={...} decorators={decorators}/>

Data Attributes

{
    id: '[optional] string',
    name: 'string',
    children: '[optional] array',
    toggled: '[optional] boolean',
    active: '[optional] boolean',
    loading: '[optional] boolean',
    decorators: '[optional] object',
    animations: '[optional] object'
},

id

The component key. If not defined, an auto-generated index is used.

name

The name prop passed into the Header component.

children

The children attached to the node. This value populates the subtree at the specific node. Each child is built from the same basic data structure. Tip: Make this an empty array, if you want to asynchronously load a potential parent.

toggled

Toggled flag. Sets the visibility of a node's children. It also sets the state for the toggle decorator.

active

Active flag. If active, the node will be highlighted. The highlight is derived from the node.activeLink style object in the theme.

loading

Loading flag. It will populate the treeview with the loading component. Useful when asynchronously pulling the data into the treeview.

decorators / animations

Attach specific decorators / animations to a node. Provides the low level functionality to create visuals on a node-by-node basis. These structures are the same as the top level props, described above.