Implementing drag drop

From ancoleman/ai-design-components · View interactive version

Implementing drag drop is an AI agent skill from the GitHub repository ancoleman/ai-design-components. Implements drag-and-drop and sortable interfaces with React/TypeScript including kanban boards, sortable lists, file uploads, and reorderable grids. Use when building interactive UIs requiring direct manipulation, spatial organization, or touch-friendly reordering.

How to use this skill

Skill file

Drag-and-Drop & Sortable Interfaces

Purpose

This skill helps implement drag-and-drop interactions and sortable interfaces using modern React/TypeScript libraries. It covers accessibility-first approaches, touch support, and performance optimization for creating intuitive direct manipulation UIs.

When to Use

Invoke this skill when:

Core Patterns

Sortable Lists

Reference references/dnd-patterns.md for:

Kanban Boards

Reference references/kanban-implementation.md for:

File Upload Zones

Reference references/file-dropzone.md for:

Accessibility

Reference references/accessibility-dnd.md for:

Library Selection

Primary: dnd-kit

Modern, accessible, and performant drag-and-drop for React.

Reference references/library-guide.md for:

Key Features

Implementation Workflow

Step 1: Analyze Requirements

Determine the drag-and-drop pattern needed:

Step 2: Set Up Library

Install required packages:

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

Step 3: Implement Core Functionality

Use examples as starting points:

Step 4: Add Accessibility

Reference references/accessibility-dnd.md to:

Run scripts/validate_accessibility.js to check implementation.

Step 5: Optimize Performance

For lists with >100 items:

Step 6: Style with Design Tokens

Apply theming using the design-tokens skill:

Mobile & Touch Support

Reference references/touch-support.md for:

State Management

Reference references/state-management.md for:

Scripts

Calculate Drop Position

Run scripts/calculate_drop_position.js to:

Generate Configuration

Run scripts/generate_dnd_config.js to:

Validate Accessibility

Run scripts/validate_accessibility.js to:

Examples

Each example includes complete TypeScript code with accessibility:

Sortable List

examples/sortable-list.tsx

Kanban Board

examples/kanban-board.tsx

File Dropzone

examples/file-dropzone.tsx

Grid Reorder

examples/grid-reorder.tsx

Assets

TypeScript Types

assets/drag-state-types.ts provides:

Configuration Schema

assets/dnd-config-schema.json defines:

Best Practices

Visual Feedback

Performance

Accessibility First

Error Handling

Common Pitfalls

Avoid These Issues

Solutions

Reference the appropriate guide for each issue:

Testing Checklist

Before deployment, verify:

Next Steps

After implementing basic drag-and-drop:

  1. Add advanced features (auto-scroll, multi-select)
  2. Implement gesture support for mobile
  3. Add animation polish with Framer Motion
  4. Create custom drag preview components
  5. Build complex interactions (nested dragging)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.