npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dnd-kit-tree

v1.0.25

Published

A sortable tree component for React

Downloads

784

Readme

dnd-kit-tree

npm license

A React-based project utilizing dnd-kit to create a customizable and interactive tree component for drag-and-drop functionality.

Features

  • Drag-and-drop support for tree nodes.
  • Customizable node rendering.
  • Lightweight and performant.

Demo

View Demo

Example Image 1

Example Image 2

Installation

npm install dnd-kit-tree @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities

Example

import { useState } from "react";
import { SortableTree, TreeItems } from "dnd-kit-tree";

type Data = {
  label: string;
};

const MyComponent = () => {
  const [value, setValue] = useState<TreeItems<Data>>([
    {
      id: "id-1",
      data: { label: "Item 1" },
      children: [
        {
          id: "id-2",
          data: { label: "Item 2" },
          children: [
            {
              id: "id-3",
              children: [],
              data: { label: "Item 3" },
            },
          ],
        },
      ],
    },
    {
      id: "id-4",
      children: [],
      data: { label: "Item 4" },
    },
    {
      id: "id-5",
      children: [],
      data: { label: "Item 5" },
    },
  ]);

  return (
    <SortableTree
      removable
      collapsible
      value={value}
      onChange={setValue}
      indentationWidth={25}
      renderItemContent={(item) => <div>{item.data?.label}</div>}
    />
  );
};

Props

| Prop | Type | Default | Description | | ------------------- | ------------------------------------------------ | ----------- | ------------------------------------------------------------ | | value | TreeItems<T> | [] | The tree data structure representing the nodes. | | maxDepth | number | undefined | The maximum depth of the tree. (undefined = Infinity) | | grabbingCursor | string | grabbing | The cursor style when dragging a tree node. | | onChange | (items: TreeItems<T>) => void | undefined | Callback function triggered when the tree structure changes. | | onMove | (action: SortableTreeMove) => void | undefined | Callback function triggered when a node is moved. | | removable | boolean | false | Enables the ability to remove tree nodes. | | collapsible | boolean | false | Enables the ability to collapse/expand tree nodes. | | indentationWidth | number | 25 | The width of indentation for child nodes in pixels. | | adjustTranslateY | number | 0 | Adjusts the vertical position of the dragged node. | | virtual | SortableTreeVirtualProps | undefined | Enables virtualization of the tree. | | renderItem | (props: RenderItemProps<T>) => React.ReactNode | undefined | Function to customize the rendering of tree nodes. | | renderItemContent | (item: FlattenedItem<T>) => React.ReactNode | undefined | Function to customize the rendering of tree node content. |

CSS Class Names

  • dnd-tree-item
  • dnd-tree-item-clone
  • dnd-tree-item-indicator
  • dnd-tree-item-container
  • dnd-tree-item-container-clone
  • dnd-tree-item-container-indicator
  • dnd-tree-item-content
  • dnd-tree-item-children-count
  • dnd-tree-item-actions
  • dnd-tree-item-action-handle
  • dnd-tree-item-action-collapse
  • dnd-tree-item-action-collapsed
  • dnd-tree-item-action-delete

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.