React Organizational Chart

2.2.1 · maintenance · verified Tue Apr 21

React Organizational Chart is a JavaScript library designed for rendering interactive hierarchy trees within React applications. Its primary distinguishing feature is the flexibility to accept any React children as node labels, enabling highly customized and rich node designs, which is a common limitation in many alternative organizational chart libraries. The current stable version is 2.2.1. While the package maintains a notable level of weekly downloads, indicating its continued utility, its development cadence is slow. The latest version was published approximately three years ago, and according to recent analyses, there have been no new releases in the past twelve months, though some minor commits have occurred more recently. It is typically employed for visualizing hierarchical data structures such as corporate organizational charts or family trees, offering styling customization through props for lines and node padding.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to create a multi-level organizational chart with custom styled nodes and configured line properties.

import React from 'react';
import { Tree, TreeNode } from 'react-organizational-chart';
import styled from 'styled-components'; // Example for custom styling

const StyledNode = styled.div`
  padding: 8px 12px;
  border-radius: 8px;
  display: inline-block;
  border: 1px solid #ddd;
  background-color: #f9f9f9;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
`;

const StyledTreeExample = () => (
  <Tree
    lineWidth={'3px'}
    lineColor={'#a0a0a0'}
    lineBorderRadius={'10px'}
    nodePadding={'15px'}
    label={<StyledNode>Root Node</StyledNode>}
  >
    <TreeNode label={<StyledNode>Child 1</StyledNode>}>
      <TreeNode label={<StyledNode>Grand Child A</StyledNode>} />
    </TreeNode>
    <TreeNode label={<StyledNode>Child 2</StyledNode>}>
      <TreeNode label={<StyledNode>Grand Child B</StyledNode>}>
        <TreeNode label={<StyledNode>Great Grand Child 1</StyledNode>} />
        <TreeNode label={<StyledNode>Great Grand Child 2</StyledNode>} />
      </TreeNode>
    </TreeNode>
    <TreeNode label={<StyledNode>Child 3</StyledNode>}>
      <TreeNode label={<StyledNode>Grand Child C</StyledNode>} />
      <TreeNode label={<StyledNode>Grand Child D</StyledNode>} />
    </TreeNode>
  </Tree>
);

export default StyledTreeExample;

view raw JSON →