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

@dnd-kit/core

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dnd-kit/core

dnd kit – a lightweight React library for building performant and accessible drag and drop experiences

  • 4.0.0-next-2021621163226
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
785K
decreased by-58.64%
Maintainers
1
Weekly downloads
 
Created

What is @dnd-kit/core?

The @dnd-kit/core package provides a comprehensive set of tools for building complex drag and drop interfaces with ease. It is designed to be highly customizable and extensible, allowing developers to implement a wide range of drag and drop scenarios, from simple list reordering to complex nested structures and beyond. The core package focuses on providing the fundamental building blocks for drag and drop functionality, leaving UI and styling decisions up to the developer.

What are @dnd-kit/core's main functionalities?

Basic Drag and Drop

This feature allows for the implementation of basic drag and drop functionality within your application. The DndContext component is used to wrap around the draggable elements, providing the necessary context for drag and drop interactions.

{"import {DndContext} from '@dnd-kit/core';

function App() {
  return (
    <DndContext>
      {/* Your draggable items here */}
    </DndContext>
  );
}"}

Sorting

This feature enables sorting functionality within a list of items. By using the DndContext in combination with sensors and a sorting utility function like arrayMove, developers can easily implement draggable lists where items can be reordered.

{"import {DndContext, useSensor, PointerSensor} from '@dnd-kit/core';
import {arrayMove} from '@dnd-kit/sortable';

function App() {
  const sensors = [useSensor(PointerSensor)];

  const handleDragEnd = (event) => {
    const {active, over} = event;

    if (active.id !== over.id) {
      setItems((items) => {
        const oldIndex = items.findIndex((item) => item.id === active.id);
        const newIndex = items.findIndex((item) => item.id === over.id);

        return arrayMove(items, oldIndex, newIndex);
      });
    }
  };

  return (
    <DndContext sensors={sensors} onDragEnd={handleDragEnd}>
      {/* Your sortable items here */}
    </DndContext>
  );
}"}

Other packages similar to @dnd-kit/core

FAQs

Package last updated on 21 Jul 2021

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