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

@dnd-kit/sortable

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dnd-kit/sortable

Official sortable preset and sensors for dnd kit

  • 5.0.0-next-2021812154850
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
increased by0.62%
Maintainers
1
Weekly downloads
 
Created

What is @dnd-kit/sortable?

The @dnd-kit/sortable package is a part of the DND Kit ecosystem that provides a set of utilities for building complex drag-and-drop interfaces with sortable capabilities. It allows developers to create sortable lists and grids that are accessible and can be customized to fit the needs of various applications.

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

Sortable Lists

This feature allows developers to create vertical lists that can be sorted using drag-and-drop. The code sample demonstrates how to set up a DndContext with sensors for pointer and keyboard interactions, and a SortableContext to manage the sortable items.

import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';

function SortableList({ items }) {
  const sensors = useSensors(
    useSensor(PointerSensor),
    useSensor(KeyboardSensor)
  );

  return (
    <DndContext sensors={sensors} collisionDetection={closestCenter}>
      <SortableContext items={items} strategy={verticalListSortingStrategy}>
        {items.map((id) => (
          <SortableItem key={id} id={id} />
        ))}
      </SortableContext>
    </DndContext>
  );
}

Sortable Grids

This feature enables the creation of sortable grids. The code sample shows how to use a DndContext with a MouseSensor and a SortableContext with a rectSortingStrategy to manage the layout of sortable items in a grid format.

import { DndContext, MouseSensor, useSensor, useSensors } from '@dnd-kit/core';
import { SortableContext, rectSortingStrategy } from '@dnd-kit/sortable';

function SortableGrid({ items }) {
  const sensors = useSensors(useSensor(MouseSensor));

  return (
    <DndContext sensors={sensors}>
      <SortableContext items={items} strategy={rectSortingStrategy}>
        {items.map((id) => (
          <SortableItem key={id} id={id} />
        ))}
      </SortableContext>
    </DndContext>
  );
}

Other packages similar to @dnd-kit/sortable

FAQs

Package last updated on 12 Sep 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