Skip to content

Repository files navigation

React Tree

Build StatusTest Coverage

React Tree is a straight forward component that allows a user to display and manage a hierarchical structure of items in a clear and comfortable way.

Optional Themes

Two optional themes are supported when using React Tree:

Basic tree

Includes all the logic, based on @emotion/core - README

Material tree

Based on the basic tree logic, using Material-UI components - README

Both options support component customization.
Examples can be found - here


Props

NameTypeDefaultDescription
structureArray[]Component input - array of leaves along with their ancestors
titleString""Title to be displayed on root mode
onSelectFunc() => {}callback when clicking a leaf
stylesObjectOptional - enables customized styles
widthnumber230 The width of the tree component
heightnumber300 The height of the tree component
noResultsTextStringNo matching resultsThe message to be displayed when having no results on searching
noResultsRendererComponentno_matching_items.jsComponent to replace the default NoResults component.
noResultsIconRendererComponentComponent to replace the default NoResultsIcon component.
headerRendererComponentheader.jsComponent to replace the default Header component.
backIconRendererComponentComponent to replace the default BackIcon component.
inputRendererComponentinput.js️Component to replace the default Input component.
inputIconRendererComponentComponent to replace the default InputIcon component.
clearIconRendererComponentComponent to replace the default CleaseIcon component.
itemRendererComponentitem.js️Component to replace the default Item component.
itemsRendererComponentitems.jsComponent to replace the default Items component.
forwardIconRendererComponentComponent to replace the default ForwardIcon component.
treeContainerRendererComponenttree_container.jsComponent to replace the default TreeContainer component.
customItemsRenderer ComponentComponent to replace the default Items && inner Item component.
selectedItemObjectOptional - enables managing selected item. The Object should contain 2 fields: item and leaf, for example: { item: ["a","b","c"], leaf: "c" }

How to Contribute

Setting up development environment

  1. Fork the repository and create your branch from master.
  2. Install the project: yarn install
  3. Run tests: yarn test or yarn test:watch
  4. Run dev environment: yarn storybook and head to https://localhost:6006

Credit

Styling patterns were taken from react-select - README

About

A lightweight, easy-to-navigate selection component that displays hierarchical tree data in a searchable, filterable layout.

Topics

Resources

Stars

20 stars

Watchers

46 watching

Forks

Releases

Packages

Used by

Contributors

Languages