All components

Optimistic Queue

AI

A list whose archive action applies optimistically — the row collapses the instant you click, before the request resolves. Success drops it; failure rolls it back, expanding it right into place. The trick: rows are never unmounted on the optimistic step, only after the request confirms, so the exit animation can reverse mid-flight with no re-mount gymnastics. A live queue tracks in-flight actions. Keyboard-accessible and monochrome.

  • Your deployment is live
    Vercel
  • 3 issues assigned to you
    Linear
  • Re: flaky test in CI
    GitHub
  • Dana left 2 comments
    Figma

Archiving fails ~40% — watch it roll back.

Installation

Terminal
npx shadcn@latest add https://ui.saumyarex.xyz/r/optimistic-queue.json

Props

PropTypeDefaultDescription
itemsT[]Initial items. The component owns the list from here (uncontrolled).
getId / getLabel(item: T) => stringStable id per item, and a human label for the queue + a11y.
onArchive(item: T) => Promise<void>Perform the real archive. Resolve to confirm the removal, throw/reject to roll it back.
children(item: T) => React.ReactNodeRender prop for each row's content.
actionLabelstring"Archive"Label for the per-row action button.

Dependencies

clsxtailwind-merge