∞ forever components

Drag & Reorder

Drag Handle

5 dark rows with grip handles spring-animate to new positions when dragged or arrow-keyed; the lifted row glows cyan and scales up slightly.

cssmedium complexitymoderate motionpointermobile-ready

Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited

Live demo — the real component, running in a sandbox. One self-contained HTML file, zero dependencies. Open it on the canvas →
1

When to use it

Settings panels, playlist editors, priority queues, or any sortable list needing tactile drag-to-reorder with keyboard accessibility.

When not to

Lists longer than ~10 items (absolute positioning covers full height). Touch-only contexts where pointer capture may conflict with scroll.

Working with an AI agent

Every component ships agent-ready metadata. An example instruction for this one:

Change accent color to dusty clay (#9b6450), increase the maximum row height in measure() from 44 to 56, keeping the available-height fit, and add a 6th row by setting N=6 and extending the order array. Theme: dark tokens live in :root, the light variant in :root[data-theme="light"]; ?theme=light or a {type:'forever:theme'} postMessage switches at runtime.

Safe to edit

  • accent color (--dr09-accent)
  • row count (N=5)
  • responsive row height (measure() caps ROWH at 44)
  • spring stiffness (K=0.18) and damping (D=0.74)
  • idle demo cadence while demoEnabled; first deliberate input disables it permanently
  • bar widths (52+i*9)%
  • idle demo cadence (D_FIRST=300 / D_WAIT=1480 / D_LIFT=500 / D_REST=520 ms,)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • IIFE wrapper
  • prefers-reduced-motion static fallback
  • visibilitychange pause/resume
  • pointerCapture for reliable drag tracking
  • idle demo hop (the same move routine the drag/keyboard path uses; real input takes over)
  • theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)
  • demo-v1 preview lifecycle: initialize demoEnabled from window.__foreverPreview and stop attract work on the window forever:interactive event; retain manual feedback, settling, cleanup and explicit sessions

Known limitations

  • Row count is fixed at build time — dynamic add/remove requires structural changes
  • Drag handle covers entire row, not just the grip icon — fine for demos but may conflict with row-level click handlers in production
  • State remains local to each mounted instance; format/theme remount preserves takeover, not component values.

drag-and-dropreorderlistspringgrip-handlekeyboardui-control

More Drag & Reorder components

  • Kanban MoveThree-column kanban board where a cyan card lifts and spring-animates between lanes via FLIP. Idle demo stops after first input; supports arrow keys and…
  • Pull to RefreshA 5-row canvas list springs down on drag, revealing diagonal bars and a rotating geometric indicator; releasing past threshold triggers a 1.5s sync spinner.
  • Sortable Grid3x3 grid of colored numbered tiles that spring-animate into position as tiles are dragged or swapped; initial idle shuffle stops after first input.
  • Dual RangeCanvas dual-range slider with two spring-driven thumbs (white lo, amber hi), hatched fill, delta readout, and tick marks. Initial breathing stops after…
  • Carousel ThrowSeven colored cards orbit a glowing hub in a radial ring; drag to fling with angular inertia, release to snap to the nearest card under the marker.
  • Spring Physics StackPriority queue you reorder by dragging: the lifted row tilts with pointer velocity and neighbours spring into place.