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

kanban-dnd

v1.0.0

Published

A custom drag-and-drop library for React with ghost indicators, FLIP animations, and Kanban board support

Downloads

2

Readme

kanban-dnd

A lightweight, performant drag-and-drop library for React with ghost indicators, FLIP animations, and Kanban board support.

Installation

npm install kanban-dnd

Features

  • 🎯 Ghost Indicators - Visual drop zones with configurable hover delays
  • 🔄 FLIP Animations - Smooth reorder animations
  • 📱 Pointer & Keyboard Sensors - Full accessibility support
  • 🎨 Headless - Bring your own styles
  • Performant - RAF throttling, cached rects, minimal re-renders
  • 📦 Tree-shakeable - Only import what you need
  • 🔷 TypeScript - Full type safety

Quick Start

import {
  DndProvider,
  useSortable,
  useDroppable,
  useDndContext,
} from 'kanban-dnd';

function App() {
  const handleDragEnd = (item, target, position) => {
    if (item.type === 'card' && position) {
      // Reorder cards
      reorderCards(item.data.listId, position.listId, item.data.index, position.index);
    }
  };

  return (
    <DndProvider onDragEnd={handleDragEnd}>
      <KanbanBoard />
    </DndProvider>
  );
}

Creating a Sortable Card

function Card({ card, index, listId }) {
  const sortable = useSortable({
    id: card.id,
    type: 'card',
    index,
    containerId: listId,
    data: { ...card, listId, index },
  });

  return (
    <div
      ref={sortable.setNodeRef}
      style={sortable.style}
      {...sortable.attributes}
      {...sortable.listeners}
      className="p-4 bg-white rounded-lg shadow"
    >
      {card.title}
    </div>
  );
}

Creating a Droppable List

function List({ list }) {
  const droppable = useDroppable({
    id: list.id,
    type: 'list',
    accepts: ['card'],
  });

  return (
    <div
      ref={droppable.setNodeRef}
      className={cn(
        'p-4 bg-gray-100 rounded-lg min-h-[200px]',
        droppable.isOver && 'ring-2 ring-blue-500'
      )}
    >
      {list.cards.map((card, index) => (
        <Card key={card.id} card={card} index={index} listId={list.id} />
      ))}
    </div>
  );
}

Advanced Usage

Ghost Indicators for Cards

import { useCardDragAnimation } from 'kanban-dnd';

function List({ list }) {
  const containerRef = useRef(null);
  const { state } = useDndContext();

  const cardAnimation = useCardDragAnimation({
    container: containerRef.current,
    mousePosition: getMousePosition(state),
    sourceListId: getDragSourceListId(state),
    draggedIndex: getDraggedIndex(state),
    destListId: list.id,
    cardCount: list.cards.length,
    enabled: isCardDragActive(state),
    hoverDelay: 400, // ms before showing ghost
  });

  return (
    <div ref={containerRef}>
      {cardAnimation.ghostVisible && cardAnimation.ghost?.p === 0 && (
        <GhostIndicator />
      )}
      {list.cards.map((card, index) => (
        <React.Fragment key={card.id}>
          <Card card={card} index={index} listId={list.id} />
          {cardAnimation.ghostVisible && cardAnimation.ghost?.p === index + 1 && (
            <GhostIndicator />
          )}
        </React.Fragment>
      ))}
    </div>
  );
}

Ghost Indicators for Lists

import { useListDragAnimation } from 'kanban-dnd';

function Board({ lists }) {
  const containerRef = useRef(null);

  const listAnimation = useListDragAnimation({
    container: containerRef.current,
    mousePosition,
    draggedIndex,
    listCount: lists.length,
    enabled: isListDragActive,
    hoverDelay: 400,
  });

  return (
    <div ref={containerRef} className="flex gap-4">
      {listAnimation.ghostVisible && listAnimation.ghostSlot === 'LEFT_END' && (
        <ListGhostZone />
      )}
      {lists.map((list, index) => (
        <React.Fragment key={list.id}>
          {listAnimation.ghostVisible && listAnimation.ghostSlot === index && (
            <ListGhostZone />
          )}
          <List list={list} index={index} />
        </React.Fragment>
      ))}
      {listAnimation.ghostVisible && listAnimation.ghostSlot === 'RIGHT_END' && (
        <ListGhostZone />
      )}
    </div>
  );
}

API Reference

Hooks

| Hook | Description | |------|-------------| | useDraggable | Make an element draggable | | useDroppable | Make an element a drop target | | useSortable | Combined draggable + droppable for sortable items | | useCardDragAnimation | Card drag animations with ghost indicators | | useListDragAnimation | List drag animations with ghost indicators | | useFLIPAnimation | Smooth layout animations on reorder | | useDragOverlay | Floating drag preview |

Context

| Export | Description | |--------|-------------| | DndProvider | Context provider - wrap your app | | useDndContext | Access current drag state | | useIsDragging | Boolean helper for drag state | | useActiveDragItem | Get the currently dragged item |

Utilities

| Function | Description | |----------|-------------| | reorder(list, startIndex, endIndex) | Reorder array items | | moveBetweenLists(source, dest, srcIdx, destIdx) | Move between arrays | | calculateNewIndex(draggedIndex, gapIndex) | Convert gap to insertion index |

TypeScript

Full TypeScript support with exported types:

import type {
  DragItem,
  DropTarget,
  InsertPosition,
  CardGhost,
  CardHoverTarget,
  DragState,
} from 'kanban-dnd';

License

MIT