Skip to content
IndexRequest a UIAboutContact

Optimistic Update & Rollback

Checking a task updates instantly and saves in the background; if the save fails, it rolls back with a message.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean UI mockup of a to-do list with four rows: the first checked with a faint small spinner on its right to show it is saving, the others unchecked, and below the list a small red message Couldn't save. Change reverted., rounded rows with thin borders, light theme, flat modern style. Variants: the saved state with a grey check, and the failed row shown with a subtle red outline. Negative: blocking spinners, modal dialogs, heavy colour, text errors, clutter. Reduced motion: static design.

About this pattern

Definition

Optimistic UI assumes success: the interface changes the moment the user acts, and the request finishes in the background. Most requests succeed, so the app feels instant. When one fails, the change is reverted and the user is told why.

Purpose & UX principles

  • Update the interface immediately and show a quiet pending cue, such as a small spinner or dimmed text.
  • On failure, restore the previous state and explain in one sentence, with a way to retry.
  • Use it only for actions that rarely fail and are easy to undo.

Interaction states

  • Four tasks you can tick, and a Fail the next save checkbox to see the rollback.

Motion specification

  • The tick appears at once; saving takes 900ms; a failure shakes the row for 300ms.
  • Reduced motion: no shake, only the message.

Responsive behaviour

  • Never apply optimism to payments or destructive actions.
  • Keep the pending cue small so the instant feeling is not lost.

Code

HTML
<div class="bx"><ul class="ls" id="ls"></ul><label class="sw"><input type="checkbox" id="fl"> Fail the next save</label><p class="out" id="out" role="status"></p></div>

Related patterns

Loading Button States

↗
Loading Button StatesButtons & Actions

Toast

↗
ToastFeedback & Notifications

Copy Feedback Button

↗
Copy Feedback ButtonMicro Interactions