Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 1 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

dnd kit Examples You Can Edit and Run

5 small dnd kit examples written by AgentGid from the official docs, one feature each. Every one runs in your browser: change the code and see the result at once, or describe a change and let AI rewrite it. The screenshots are taken from the same code by our server, which also checks that each example starts without errors.

dnd kit: usage and stats 151 AI-built projects use it

Try them all in one place

import { useState } from 'react';
import { DndContext, useDraggable, useDroppable } from '@dnd-kit/core';
import { CSS } from '@dnd-kit/utilities';

function Draggable({ children }) {
  const { attributes, listeners, setNodeRef, transform } = useDraggable({ id: 'draggable' });
  const style = {
    transform: CSS.Translate.toString(transform),
    position: 'relative', zIndex: 2, touchAction: 'none', cursor: 'grab',
    padding: '12px 20px', border: 0, borderRadius: 10,
    background: '#6366f1', color: '#fff', font: '600 15px system-ui',
  };
  return <button ref={setNodeRef} style={style} {...listeners} {...attributes}>{children}</button>;
}

function Droppable({ children }) {
  const { isOver, setNodeRef } = useDroppable({ id: 'droppable' });
  return (
    <div ref={setNodeRef} style={{
      width: 240, height: 160, display: 'grid', placeItems: 'center', borderRadius: 14,
      border: `2px dashed ${isOver ? '#22c55e' : '#555'}`,
      background: isOver ? 'rgba(34,197,94,0.12)' : '#1b1b1b',
      color: isOver ? '#4ade80' : '#aaa', font: '15px system-ui',
    }}>
      {children}
    </div>
  );
}

export default function App() {
  const [isDropped, setIsDropped] = useState(false);
  const draggableMarkup = <Draggable>Drag me</Draggable>;

  function handleDragEnd(event) {
    // Was the item released over the drop zone?
    setIsDropped(Boolean(event.over && event.over.id === 'droppable'));
  }

  return (
    <div style={{ height: 360, background: '#111', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 48 }}>
      <DndContext onDragEnd={handleDragEnd}>
        <div style={{ width: 130, display: 'grid', placeItems: 'center', color: '#666', font: '13px system-ui' }}>
          {!isDropped ? draggableMarkup : 'empty'}
        </div>
        <Droppable>{isDropped ? draggableMarkup : 'Drop here'}</Droppable>
      </DndContext>
    </div>
  );
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Drag the purple button into the dashed box; drop it outside the box to move it back. Code written by AgentGid [1]. How it works, with a screenshot →

Checked Oct 12, 2026: each example starts without errors in Chromium with @dnd-kit/core 6.3.1, react 19.3.0, react-dom 19.3.0, @dnd-kit/utilities 3.2.2, @dnd-kit/sortable 10.0.0. Needs WebGL.

Sources

  1. Docs: introduction › getting-started
  2. Docs: api-documentation › droppable
  3. Docs: presets › sortable
  4. Docs: api-documentation › draggable

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with dnd kit? Ask AgentGid →