npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

svelte-reactive-dnd

v0.4.1

Published

A drag and drop library for Svelte

Readme

svelte-reactive-dnd

A drag and drop library for Svelte

Includes support for:

  • Nested Lists
  • Horizontal and Vertical Lists
  • Movement between lists
  • Conditional drag and drop
  • Drag Handles
  • List capacity
  • Mixed sized items
  • Override drop position, with autoscroll

Getting Started

Install the library

npm install svelte-reactive-dnd

or

yarn add svelte-reactive-dnd

Start using the parts!

<script>
    import { DropList, DragHandle } from 'svelte-reactive-dnd';
    let items = [
        { id: 1, title: 'Apple' },
        { id: 2, title: 'Banana' },
        { id: 3, title: 'Cherry' },
    ];
</script>

<div class="list">
    <DropList
        {items}
        on:itemdroppedin="{({ detail }) => (items = detail.listSnapshot)}"
    >
        <div slot="listItem" let:data="{{ item }}">
            <DragHandle itemId="{item.id}">
                            <div class="item">
                                <p>{item.title}</p>
                            </div>
            </DragHandle>
        </div>
    </DropList>
</div>

<style>
    .list {
        height: 200px;
        width: 100px;
        border: solid black 1px;
        background-color: grey;
    }
    .item {
        margin: 2px;
        width: 78px;
        padding: 0px 8px;
        border: solid black 1px;
        background-color: burlywood;
    }
</style>

Play with this Example

More Examples

Design

svelte-reactive-dnd manages your lists internally, creating a few internal divs to handle measurements and events. It uses padding to manipulate the position of items in the list, relying on the browser's layout engine to animate things properly. In my tests in Chrome, this was fairly performant with lists of up to 500 items, but please file an issue if you se otherwise!

DropList maintains a cached copy of the items it was provided. This cache is not updated during dragging to simplify list management and provide better UX. The itemdroppedin event provides multiple views of how the list was manipulated that may be useful in reconciling any changes. But in the simple case, listSnapshot should work great.

DragHandle and DropGroup are provided to reduce the amount of wiring one has to do when building more complex drag and drop experiences, hopefully simplifying common use cases. They are not required. With a little bit of wiring, anything they add can be done manually. To that end, they are very simple, and provide little configuration.

API

WARNING: API IS NOT YET STABLE. Will stabilize on version 1.0.0.

There are 4 exports from this library: