Giter Site home page Giter Site logo

joelsmithucl / react-organizational-chart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daniel-hauser/react-organizational-chart

0.0 0.0 0.0 8.39 MB

Simple react hierarchy tree - any React children accepted for nodes

Home Page: https://daniel-hauser.github.io/react-organizational-chart

License: MIT License

JavaScript 3.41% TypeScript 96.59%

react-organizational-chart's Introduction

react-organizational-chart

Simple react hierarchy tree - any React children accepted for nodes

CI NPM styled with prettier

Install

npm install --save react-organizational-chart

Usage

import React from 'react';
import { Tree, TreeNode } from 'react-organizational-chart';

const ExampleTree = () => (
  <Tree label={<div>Root</div>}>
    <TreeNode label={<div>Child 1</div>}>
      <TreeNode label={<div>Grand Child</div>} />
    </TreeNode>
  </Tree>
);

Examples

Styled tree

styled tree example

const StyledNode = styled.div`
  padding: 5px;
  border-radius: 8px;
  display: inline-block;
  border: 1px solid red;
`;

const StyledTreeExample = () => (
  <Tree
    lineWidth={'2px'}
    lineColor={'green'}
    lineBorderRadius={'10px'}
    label={<StyledNode>Root</StyledNode>}
  >
    <TreeNode label={<StyledNode>Child 1</StyledNode>}>
      <TreeNode label={<StyledNode>Grand Child</StyledNode>} />
    </TreeNode>
    <TreeNode label={<StyledNode>Child 2</StyledNode>}>
      <TreeNode label={<StyledNode>Grand Child</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 1</StyledNode>} />
      <TreeNode label={<StyledNode>Grand Child 2</StyledNode>} />
    </TreeNode>
  </Tree>
);

Interactive examples can be found here

Components

Tree - The root of the tree

Accepts the following props:

  • label: (required) Any react Node
  • children: (required) Any number of <TreeNode>
  • lineHeight: (default 20px) The height of the Path as a css length
  • lineWidth: (default 1px) The width of the Path as a css length
  • lineColor: (default black) The color of the Path as a css color
  • lineStyle: (default solid) The line style as a css line-style
  • lineBorderRadius: (default 5px) The border radius of the Path as a css border-radius
  • nodePadding: (default 5px) The left and right padding of every <TreeNode> as a css length

TreeNode - A node in the tree

  • label: (required) Any react Node
  • children: (required) Any number of <TreeNode>

Motivation

I created react-organizational-chart because i could not find any other react organizational chart that supports react components as nodes.

Alternatives

  • org-chart is highly customizable but can't render React components as nodes.

License

MIT © daniel-hauser

react-organizational-chart's People

Contributors

daniel-hauser avatar bopzor avatar dependabot[bot] avatar kimjisena avatar alvesjtiago avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.