Swapy
A framework-agnostic tool that converts any layout into a drag-to-swap one with just a few lines of code.
A framework-agnostic tool that converts any layout into a drag-to-swap one with just a few lines of code.
Project Views
last year
New Users
+10%
We Build Future of
Design Industry
Daily New clients
SK-Modernist
Smart Digital
Agency For Your
Business
500+ Users
Don't Take Our Words For It...
npx uilayouts@latest add swapy
1<SwapyLayout id="swapy" >2<SwapySlot id="slot-1">3<SwapyItem id="item-1">4<DragHandle />5Item 16</SwapyItem>7<SwapyItem id="item-2">8<DragHandle />9Item 210</SwapyItem>11<SwapyItem id="item-3">12<DragHandle />13Item 314</SwapyItem>15</SwapySlot>16</SwapyLayout>
SwapyLayout
Props
Props | Type | Default | Description |
---|---|---|---|
id | string | — | A unique identifier for the layout container. |
enable | boolean | — | Whether to enable drag-and-drop (currently unused in logic). |
onSwap | (event: { newSlotItemMap: { asArray: SlotItemMapArray } }) => void | — | Callback fired when an item is swapped. |
config | Partial<{ animation: "dynamic" | "spring" | "none"; continuousMode: boolean; manualSwap: boolean; swapMode: "hover" | "drop"; autoScrollOnDrag: boolean; }> | {} | Configuration object for swapy behavior. |
className | string | — | Additional class names to apply to the layout container. |
children | React.ReactNode | — | Child components (usually SwapySlot s containing SwapyItem s). |
SwapyItem
Props
Prop | Type | Default | Description |
---|---|---|---|
id | string | — | Unique identifier for the draggable item. |
className | string | — | Additional class names. |
children | React.ReactNode | — | Content to render inside the draggable item. |
dragItemOpacity | number (10–100) | 100 | Tailwind opacity value applied when item is being dragged (e.g., 50 = 50%). |
SwapySlot
Props
Prop | Type | Default | Description |
---|---|---|---|
id | string | — | Unique identifier for the slot (drop target). |
className | string | — | Additional class names. |
children | React.ReactNode | — | Content to render inside the slot. |
DragHandle
Props
Prop | Type | Default | Description |
---|---|---|---|
className | string | — | Optional class names for the handle. |