|
1 | | -<img src="https://s3.amazonaws.com/cdn.formk.it/web-assets/drag-and-drop.gif" alt="FormKit Drag & Drop" width="250" height="250"> |
| 1 | +<p align="center"> |
| 2 | + <a href="https://drag-and-drop.formkit.com"> |
| 3 | + <img src="https://drag-and-drop.formkit.com/og.png" alt="FormKit Drag & Drop — a tiny declarative library for modern apps" width="640"> |
| 4 | + </a> |
| 5 | +</p> |
2 | 6 |
|
3 | | -[](https://github.com/formkit/drag-and-drop/actions/workflows/ci.yml) |
4 | | - |
| 7 | +<p align="center"> |
| 8 | + <a href="https://github.com/formkit/drag-and-drop/actions/workflows/ci.yml"><img src="https://github.com/formkit/drag-and-drop/actions/workflows/ci.yml/badge.svg" alt="Tests"></a> |
| 9 | + <a href="https://www.npmjs.com/package/@formkit/drag-and-drop"><img src="https://img.shields.io/npm/v/%40formkit%2Fdrag-and-drop?color=fe44dc&label=npm" alt="npm version"></a> |
| 10 | + <a href="https://bundlephobia.com/package/@formkit/drag-and-drop"><img src="https://img.shields.io/bundlephobia/minzip/%40formkit%2Fdrag-and-drop?color=409baf&label=gzip" alt="gzip size"></a> |
| 11 | + <a href="https://github.com/formkit/drag-and-drop/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/%40formkit%2Fdrag-and-drop?color=8b32c9" alt="MIT license"></a> |
| 12 | +</p> |
5 | 13 |
|
6 | 14 | ## Introduction |
7 | 15 |
|
8 | | -FormKit’s Drag and Drop is a small library for adding data-first drag and drop sorting and transferring for lists in your app. It’s simple, flexible, framework agnostic, and clocks in at only ~4Kb gzipped. |
| 16 | +FormKit's Drag and Drop is a small library for adding data-first drag and drop sorting and transferring of lists to your app. It's **simple**, **flexible**, **framework agnostic**, and clocks in at only **~4Kb gzipped**. |
9 | 17 |
|
10 | | -<a href="https://drag-and-drop.formkit.com"> |
11 | | -Check out the docs here! |
12 | | -</a> |
| 18 | +Data-first means your array is the source of truth: drag an item and your data reorders with it — no DOM spelunking, no sortable-state to sync. It ships with first-class wrappers for **React**, **Vue**, and **Solid**, works in plain **JS/TS**, and has built-in support for multi-drag, animations, insert indicators, drop zones, drag handles, and list-to-list transfers. |
| 19 | + |
| 20 | +## Quick start |
| 21 | + |
| 22 | +```bash |
| 23 | +npm install @formkit/drag-and-drop |
| 24 | +``` |
| 25 | + |
| 26 | +```jsx |
| 27 | +import { useDragAndDrop } from "@formkit/drag-and-drop/react"; |
| 28 | + |
| 29 | +export function Tapes() { |
| 30 | + const [ref, tapes] = useDragAndDrop([ |
| 31 | + "Depeche Mode", |
| 32 | + "Duran Duran", |
| 33 | + "Pet Shop Boys", |
| 34 | + "Kraftwerk", |
| 35 | + ]); |
| 36 | + |
| 37 | + return ( |
| 38 | + <ul ref={ref}> |
| 39 | + {tapes.map((tape) => ( |
| 40 | + <li key={tape}>{tape}</li> |
| 41 | + ))} |
| 42 | + </ul> |
| 43 | + ); |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +That's a fully sortable list — drag the items and `tapes` stays in order. The same API is available for Vue, Solid, and vanilla JS/TS. |
| 48 | + |
| 49 | +<p align="center"> |
| 50 | + <a href="https://drag-and-drop.formkit.com"> |
| 51 | + <img src="https://raw.githubusercontent.com/formkit/drag-and-drop/main/docs/public/img/read-the-docs.svg" alt="Read the docs" width="300"> |
| 52 | + </a> |
| 53 | +</p> |
13 | 54 |
|
14 | 55 | --- |
15 | 56 |
|
16 | | -Created by the <a href="https://formkit.com">FormKit team</a>. |
| 57 | +<p align="center"> |
| 58 | + Created by the <a href="https://formkit.com">FormKit team</a> · MIT License |
| 59 | +</p> |
0 commit comments