More Premium Hugo Themes Premium Svelte Themes

Svelte Sortable List

A svelte 3 component that implements a list with animated drag-n-drop functionality.

Svelte Sortable List

A svelte 3 component that implements a list with animated drag-n-drop functionality.

Author Avatar Theme by brunomolteni
Github Stars Github Stars: 124
Last Commit Last Commit: Jan 14, 2020 -
First Commit Created: Dec 18, 2023 -
Svelte Sortable List screenshot

Overview

The SortableList component is a versatile tool that allows users to render a list of items that can be reordered by dragging and dropping. It also implements the FLIP animation for smooth transitions when adding, removing, or reordering items in the list. To use this component, you need to set the list prop and respond to the on:reorder event.

Features

  • Drag and drop functionality for reordering items in the list.
  • FLIP animation for smooth transitions when adding, removing, or reordering items.
  • Customizable list item element.
  • Ability to access item data and index.

Installation

To install the SortableList component, follow these steps:

  1. Install the package using npm:
npm install sortable-list
  1. Import the SortableList component into your project:
import SortableList from 'sortable-list';
  1. Use the SortableList component in your code:
<SortableList list={myList} on:reorder={handleReorder} />

Make sure to replace myList with the actual list you want to render and handleReorder with the function that will be called when items are reordered.

Summary

The SortableList component is a powerful tool that enables users to create dynamic lists with drag and drop functionality. It provides smooth animations and customizable options for list items. By following the installation guide and utilizing the available props and events, developers can easily integrate this component into their projects.