BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/moumenlab/drag-to-reorder-list

Drag-to-Reorder List

moumenlab/drag-to-reorder-list
FreeComponent

A reorderable list where siblings glide one slot and the drop plays a FLIP, keyboard included.

Live preview

live · rendered by the registry
Rendered by moumenlab on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://lab.moumen.dev/r/drag-to-reorder-list.json

Source

registry/lab/drag-to-reorder-list/drag-to-reorder-list.tsxlab.moumen.dev/r/drag-to-reorder-list.json · first 6 KB
1"use client";
2
3import { useEffect, useLayoutEffect, useRef, useState } from "react";
4import { MotionConfig, animate, motion, useReducedMotion, type MotionValue, motionValue } from "motion/react";
5
6// Drag-to-reorder list with FLIP.
7//
8// Three motion systems working together without fighting, all driven through
9// motion/react's motion values:
10//
11// 1. The dragged card follows the pointer RAW - its y motion value is
12// `jump()`ed straight from the pointermove handler (no easing: any easing
13// between hand and card reads as lag; no React render on the hot path).
14// 2. Siblings glide out of the way: as the dragged card crosses slot
15// boundaries each displaced sibling's y is `animate()`d exactly one slot -
16// retargetable, so reversing mid-glide just works.
17// 3. The drop is a FLIP: capture First rects before the commit, let React
18// reflow, then Invert each card back to its old screen pixels and
19// `animate()` it home. Nothing jumps.
20//
21// Plus rubber-banding past the ends (4:1 damped), pointer capture, multi-touch
22// protection, and a full keyboard path (grip → Space grabs → arrows move →
23// Escape cancels) narrated to screen readers. Requires the lab-theme tokens.
24// Fully Tailwind, no CSS files.
25
26const DRAG_THRESHOLD = 4;
27const EASE = [0.22, 1, 0.36, 1] as const;
28const MOVE = { duration: 0.2, ease: EASE } as const;
29const LIFT = { duration: 0.16, ease: EASE } as const;
30
31export interface ReorderItem {
32 id: string;
33 label: string;
34 meta?: string;
35}
36
37export interface ReorderState {
38 order: string[];
39 dragging: string | null;
40 from: number | null;
41 to: number | null;
42 grabbed: boolean;
43 lastMove: { label: string; from: number; to: number } | null;
44}
45
46interface DragData {
47 row: HTMLLIElement;
48 pointerId: number;
49 index: number;
50 startY: number;
51 active: boolean;
52 slot: number;
53 to: number;
54 rows?: HTMLLIElement[];
55}
56
57export default function DragReorderList({
58 items: controlledItems,
59 defaultItems = DEFAULT_ITEMS,
60 onReorder,
61 flip = true,
62 inspect = false,
63 onStateChange,
64}: {
65 /** Controlled item order; pair with onReorder. Omit for uncontrolled. */
66 items?: ReorderItem[];
67 defaultItems?: ReorderItem[];
68 onReorder?: (items: ReorderItem[]) => void;
69 /** false = hard snap, no glides/FLIP. */
70 flip?: boolean;
71 inspect?: boolean;
72 onStateChange?: (state: ReorderState) => void;
73}) {
74 const [uncontrolled, setUncontrolled] = useState(controlledItems ?? defaultItems);
75// … truncated

What it pulls in

npm packages

  • motion

Other registry items

  • https://lab.moumen.dev/r/lab-theme.json

Files it writes

  • registry/lab/drag-to-reorder-list/drag-to-reorder-list.tsx

Facts

Registry
moumenlab
Type
registry:component
Access
Free
Files written
1
Licence
MIT
In the index
at or before 2026-08-11
Last confirmed
today

Go to the source

Docs on moumenlab lab.moumen.dev moumen-soliman/lab on GitHub Raw registry item This item as JSON

More from moumenlab

All 14 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Caret-Anchored Mention Popovercaret-mention-popovermoumenlabComponentsFree1 dep
Command Palette with Argument Chipscommand-palettemoumenlabComponentsFree1 dep
File Upload Staging Areafile-upload-stagingmoumenlabComponentsFree1 dep
Hover-Expand Icon Striphover-expand-icon-stripmoumenlabComponentsFree1 dep
Inertial Wheel Listinertial-wheel-listmoumenlabComponentsFree1 dep
Morphing Checkout Flowmorphing-checkoutmoumenlabComponentsFree1 dep
OTP Segmented Inputotp-segmented-inputmoumenlabComponentsFree1 dep
Schedule Builderschedule-buildermoumenlabComponentsFree1 dep

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex