Mark Yo

Sortable List

Component

About

A drag-to-reorder list where only a grip handle lifts a row, with spring animations and a full keyboard interaction path for accessible reordering.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Sortable List to your project and fits it to your theme.

Code

How Sortable List is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { SortableList } from "@/components/ui/sortable-list";

import { useState } from "react";

type Task = { id: string; title: string };

function SortableListDemo() {
  const [items, setItems] = useState<Task[]>([
    { id: "1", title: "Write proposal" },
    { id: "2", title: "Review pull request" },
    { id: "3", title: "Plan sprint" },
    { id: "4", title: "Ship release" },
  ]);

  return (
    <div className="w-full max-w-sm">
      <SortableList
        items={items}
        onChange={setItems}
        getLabel={(item) => item.title}
        renderItem={(item) => (
          <span className="text-sm font-medium">{item.title}</span>
        )}
      />
    </div>
  );
}

export default SortableListDemo;

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    66
  • Pricing Table

    Pricing Table

    24
  • Bento Grid

    Bento Grid

    8
  • Wallet Card

    Wallet Card

    4
  • Expandable Tabs

    Expandable Tabs

    4
  • Image Gallery

    Image Gallery

    3
  • CTA Section

    CTA Section

    3
  • Bar Chart

    Bar Chart

    1