Frontend Blocks
typescript
Intermediate
Drag and Drop with dnd-kit
Sortable list using dnd-kit — accessible drag-and-drop with keyboard support.
typescript
import { DndContext, closestCenter } from "@dnd-kit/core";
import { SortableContext, useSortable, arrayMove } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
function SortableItem({ id }: { id: string }) {
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id });
return (
<div ref={setNodeRef}
style={{ transform: CSS.Transform.toString(transform), transition }}
{...attributes} {...listeners}
className="p-4 bg-slate-800 rounded-xl cursor-grab">
{id}
</div>
);
}
Prerequisites
- @dnd-kit/core >= 6
- React >= 17
Pro Tips
- → Use DragOverlay for smooth drag preview.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- typescript
- Level
- Intermediate
- Read time
- 5 min
- Published
- Oct 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
Copy to Clipboard Button
React component that copies text to clipboard and shows a Copied! confirmation.
typescript
·
Beginner
Framer Motion Fade-In Wrapper
Reusable component that fades any child element in on mount.
typescript
·
Beginner
Compound Component Pattern
Implement a flexible Tabs component using React Context and compound component pattern.
typescript
·
Intermediate