Use Actions vs Attachments
mainChoose between standard Svelte actions or the {@attach} factory based on your component structure:
use:draggable/use:droppable: Use these for plain HTML elements within your current component.attachDraggable/attachDroppable: Use these for custom Svelte components (requires Svelte 5.29+). The component must spread its props onto a root element (e.g.,<div {...props}>).
Best Practice: When using attachments, pass a getter function to the attachment so that the options (like container or dragData) remain reactive when your data changes.
<Card
{@attach attachDraggable(() => ({
container: columnId,
dragData: task
}))}
>
{task.title}
</Card>
<Column
{@attach attachDroppable(() => ({
container: columnId,
callbacks: { onDrop: handleDrop }
}))}
>
<!-- cards -->
</Column>