Skip to content

noxxxxxxxx/react-tree

Repository files navigation

Figma Tree

npm npm Donate npm bundle size

A React tree component that looks similar to Figma tree.

A tree ui component that has all the tree functionalities.

Support multiple themes and assemble the desired style through API.

Document & Demo

https://noxxxxxxxx.github.io/figma-tree/

How to use

In an ideal scenario, we only store the necessary data in the database. When retrieving data to construct a tree, we may need to extend some attributes in the tree nodes to align with our custom logic. So we need an API fieldNames to tell the component which nodes can be inserted into other nodes.

Confirm whether the attributes are consistent. If they are not consistent, use fieldNames to set them.

import Tree from 'figma-tree'
import 'figma-tree/dist/style.css'

export default App () => {
  const data= []
  const config = {}

  return (
    return (
    <Tree
      {...config}
      data={data}
    />
  )
  )
}

Feature

  • copy node
  • paste node
  • cut node
  • fold node
  • hidden node
  • lock node
  • move node
  • remove node
  • select single node
  • select multi nodes
  • context menu
  • change selected color
  • node icon
  • custom indent size
  • draggable
  • theme option

Develop

Feel free to fork or clone this repository.

pnpm i

npm run dev

LICENSE

This repository is published under MIT license