DragAndDrop
Reorderable list with drag and keyboard support
Item 1
Item 2
Item 3
Use the reorder handle and Arrow Up and Arrow Down to move items. Drag with a pointer to reorder, and press Escape to cancel an active drag.
Accessibility
- Provide a clear accessible name for every interactive target and keep the action model consistent.
- Match keyboard behavior to the established widget pattern rather than inventing a custom key map.
Styled quick start
Copy this entrypoint first. It includes the imports required to get the component on screen.
svelte
<script lang="ts">
import '@dryui/ui/themes/default.css';
import '@dryui/ui/themes/dark.css';
import { DragAndDrop } from '@dryui/ui';
</script>
<DragAndDrop.Root>
<DragAndDrop.Item>...</DragAndDrop.Item>
<DragAndDrop.Handle>...</DragAndDrop.Handle>
<DragAndDrop.Group>...</DragAndDrop.Group>
</DragAndDrop.Root> Import options
Root package
ts
import { DragAndDrop } from '@dryui/ui' Per-component subpath
ts
import { DragAndDrop } from '@dryui/ui/drag-and-drop' API
Props, CSS variables, and the public data attributes you can target when styling.
| Prop | Type | Description | Default | Required | Bindable |
|---|---|---|---|---|---|
DragAndDrop.Root | |||||
| items | T[] | — | — | ✓ | — |
| onReorder | (items: T[]) => void | — | — | ✓ | — |
| orientation | verticalhorizontal | Horizontal or vertical layout direction. | 'vertical' | — | — |
| listId | string | — | — | — | — |
| children | Snippet | Content rendered inside the component. | — | ✓ | — |
DragAndDrop.Item | |||||
| index | number | — | — | ✓ | — |
| children | Snippet<[{ isDragging: boolean; isOver: boolean }]> | Content rendered inside the component. | — | ✓ | — |
DragAndDrop.Handle | |||||
| index | number | — | — | ✓ | — |
| children | Snippet | Content rendered inside the component. | — | — | — |
DragAndDrop.Group | |||||
| onMove | (fromListId: string, fromIndex: number, toListId: string, toIndex: number) => void | — | — | ✓ | — |
| children | Snippet | Content rendered inside the component. | — | ✓ | — |