Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

draggable-tree-view

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draggable-tree-view

A simple and customizable tree view for React with drag-n-drop for repositioning.

  • 0.1.18
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Simple tree view component in React + TypeScript

A simple and customizable Tree View React component. It supports items reordering and moving between tree branches with drag-n-drop.

Installation

# Using Yarn
npm i draggable-tree-view --save

or

# Using Npm
yarn add draggable-tree-view

Sample

import { TreeView, TreeNode } from "draggable-tree-view"
import 'draggable-tree-view/dist/style.css';

const treeDataSample: TreeNode[] = [
  new TreeNode({ id: 1, title: 'Root Item 1', position: 1, canHaveParent: false }),
  new TreeNode({ id: 2, title: 'Root Item 2', position: 2, canHaveParent: false }),
  new TreeNode({ id: 3, title: 'Child Item 1 of Root 1 id 3', position: 1, parentId: 1, canHaveChildren: false }),
  new TreeNode({ id: 4, title: 'Child Item 2 of Root 1 id 4', position: 2, parentId: 1, canHaveChildren: false }),
  new TreeNode({ id: 5, title: 'Child Item 1 of Root 2 id 5', position: 1, parentId: 2, canHaveChildren: false }),
  new TreeNode({ id: 6, title: 'Branch Item 3 id 6', position: 2, parentId: 1 }),
  new TreeNode({ id: 7, title: 'Child Item 1 of Branch 3 id 7', position: 1, parentId: 6, canHaveChildren: false }),
];

function App() {
  return (
    <>
      <h1>Draggable tree</h1>
      <TreeView items={treeDataSample} onRenderItem={(node) => <div>{node.title}</div>}/>
    </>
  )
}

License

This project is licensed under the MIT License. For more information, see the LICENSE file.

Support

For support and bug reports, please open an issue on GitHub.

FAQs

Package last updated on 19 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc