npm install @shopify/draggable

The JavaScript Drag & Drop library your grandparents warned you about.

About @shopify/draggable

The npm package @shopify/draggable is a robust and flexible JavaScript library designed to enhance the drag-and-drop functionality of your web applications. Developed by Shopify, it aims to provide a smooth and accessible user interface experience, allowing for the seamless manipulation of elements within a webpage. One of the standout features of @shopify/draggable is its extensive support for touch devices, making it an ideal choice for modern, mobile-friendly web designs. Additionally, the library is lightweight and modular, enabling developers to include only the features they need, which keeps the load times fast and efficient.

To integrate this powerful drag-and-drop functionality into your project, simply use the command npm install @shopify/draggable. This command downloads and installs the library into your project, allowing you to begin implementing sophisticated drag-and-drop interfaces immediately. The package is well-maintained and regularly updated, ensuring compatibility with the latest web standards and technologies. Moreover, @shopify/draggable supports various customization options, giving developers the flexibility to tailor the behavior and appearance of the drag-and-drop elements to suit specific requirements.

@shopify/draggable stands out in the developer community due to its ease of use and comprehensive documentation. The library not only supports basic drag-and-drop operations but also offers advanced features such as sortable lists, swappable elements, and droppable zones, which can significantly enhance the interactivity of any website. By utilizing @shopify/draggable, developers can create more engaging and interactive user experiences, leading to increased user satisfaction and retention. Whether you're building a complex web application or a simple interactive feature, @shopify/draggable provides the tools necessary to implement effective and efficient drag-and-drop functionality.

More from Shopify

Shopify npm packages

Find the best node modules for your project.

Search npm

@shopify/flash-list

FlashList is a more performant FlatList...

Read more
,

@shopify/polaris-icons

[![npm version](https://img.shields.io/npm/v/@shopify/polaris-icons.svg?style=flat)](https://www...

Read more
,

@shopify/polaris

Shopify’s admin product component...

Read more
,

@shopify/cli-kit

A set of utilities, interfaces, and models that are common across all the platform...

Read more
,

@shopify/cli

A CLI tool to build for the Shopify...

Read more
,

@shopify/draggable

The JavaScript Drag & Drop library your grandparents warned you about...

Read more
,

@shopify/app-bridge-core

**[Join our team and work on libraries like this one.](https://www.shopify...

Read more
,

@shopify/theme-check-common


Read more

,

@shopify/graphql-client

Shopify GraphQL Client - A lightweight generic GraphQL JS client to interact with Shopify GraphQL...

Read more
,

@shopify/storefront-api-client

Shopify Storefront API Client - A lightweight JS client to interact with Shopify's Storefront...

Read more
,

@shopify/restyle

A system for building constraint-based UI...

Read more
,

@shopify/theme-check-node

This is the Node.js wrapper of the runtime-agnostic [`@shopify/theme-check-common`](https://npm...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

@babel/core, @babel/plugin-proposal-decorators, @babel/preset-env, @babel/preset-typescript, @changesets/changelog-github, @changesets/cli, @rollup/plugin-babel, @rollup/plugin-commonjs, @rollup/plugin-node-resolve, @rollup/plugin-typescript, @shopify/eslint-plugin, @shopify/prettier-config, @shopify/typescript-configs, @types/jest, @types/node, concurrently, esdoc, esdoc-ecmascript-proposal-plugin, esdoc-standard-plugin, eslint, jest, jest-environment-jsdom, prettier, rollup, rollup-plugin-cleanup, rollup-plugin-includepaths, rollup-plugin-node-externals, timers, tsc-alias, typescript, uglify-js

Documentation

A README file for the @shopify/draggable code repository. View Code

npm version CI PRs Welcome Bundle size

Development

Draggable is no longer maintained by its original authors. Maintenance of this repo has been passed on to new collaborators and is no longer worked on by anyone at Shopify.

We are still looking for more maintainers! If anyone is interested in answering / triaging issues, reviewing / rejecting / approving PRs, and authoring code for bug fixes / new features — please send an email to max.hoffmann (at) shopify (dot) com. You may be asked a few questions before obtaining collaboration permission, but if everything checks out, we will happily add you as a collaborator.


Get complete control over drag and drop behaviour with Draggable! Draggable abstracts native browser events into a comprehensive API to create a custom drag and drop experience. Draggable comes with additional modules: Sortable, Droppable, Swappable. Draggable itself does not perform any sorting behaviour while dragging, but does the heavy lifting, e.g. creates mirror, emits events, manages sensor events, makes elements draggable.

The additional modules are built on top of Draggable and therefore provide a similar API interface, for more information read the documentation below.

Features

Table of Contents

Install

You can install the library via npm.

npm install @shopify/draggable --save

or via yarn:

yarn add @shopify/draggable

or via CDN

<!-- Entire bundle -->
<script type="module">
  import {
    Draggable,
    Sortable,
    Droppable,
    Swappable,
  } from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.mjs';
</script>
<!-- Draggable only -->
<script type="module">
  import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
</script>
<!-- Sortable only -->
<script type="module">
  import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
</script>
<!-- Droppable only -->
<script type="module">
  import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.mjs';
</script>
<!-- Swappable only -->
<script type="module">
  import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.mjs';
</script>
<!-- Plugins only -->
<script type="module">
  import * as Plugins from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/index.mjs';
</script>
<!-- UMD browser -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable/build/umd/index.min.js"></script>
<script>
  console.log(window.Draggable);
</script>

Browser Compatibility

Check the "browserlist" property in package.json for more info

Chrome Firefox Opera Safari Edge
Last 3 versions ✔ Last 3 versions ✔ Last 3 versions ✔ Last 3 versions ✔ Last 3 versions ✔

Documentation

You can find the documentation for each module within their respective directories.

TypeScript

Draggable includes TypeScript definitions.

Documentation

Running examples

To run the examples project locally, simply run the following from the draggable root:

yarn && yarn start

This will start a server that hosts the contents of examples/. It also watches for file changes from both src/ and examples/src and reloads the browser.

Contributing

Contributions are more than welcome, the code base is still new and needs more love.

For more information, please checkout the contributing document.

Related resources

Copyright

Copyright (c) 2018-present Shopify. See LICENSE.md for further details.