Skip to content
Search
Search the documentation
Types
GitHub 0

Types

The default item type.

The other exported types are documented next to what uses them: Options with dndzone, DndConfig and AriaStrings with configure, and DndEvent, DndEventInfo and TransformDraggedElementFunction with the events.

Item

The shape of an item when no item type is given: any object. Every item needs an id under the id key, id unless configure({ idKey }) changes it, which the zone checks at runtime. The public generics take T extends object instead, since an interface without an index signature does not assign to this type.

type Item = Record<string, unknown>

Give the zone your own item type instead, and the events and callbacks are typed with it:

			<script lang="ts">
    import { dndzone, type DndEvent } from "@lukez/svelte-dnd";

    interface Dog {
        id: number;
        name: string;
        breed: string;
    }

    let dogs = $state<Dog[]>([]);

    // e.items is Dog[], and e.info.id is a number
    function update(e: DndEvent<Dog>) {
        dogs = e.items;
    }
</script>

<ul {@attach dndzone(() => ({ items: dogs, onconsider: update, onfinalize: update }))}>
    {#each dogs as dog (dog.id)}
        <li>{dog.name}</li>
    {/each}
</ul>
		
Edit this page Last updated: Nov 22, 2026