Skip to content

Latency states

Not a component: a state. useLatency() runs a request through idle, pending, skeleton, slow and settled phases from one pure reducer. A response under the skeleton threshold never flashes a placeholder; past the slow threshold the interface says how long it has been and can offer Cancel; failure offers Retry; late results are ignored. The async button runs on a slice of the same machine (no skeleton, no cancel), and the loading region here runs on all of it. The demo has a latency slider, an outcome toggle and a timestamped log of every event. With reduced motion the skeleton is still and nothing fades.

  • State Machine
  • useReducer
  • AbortController
  • aria-live
  • prefers-reduced-motion

latency-adapt

Nothing loaded yet.

The next request

State

  1. idle
  2. pending
  3. skeleton
  4. slow
  5. success
  6. error
  7. cancelled

Legal from here: START

Event log

Nothing yet. Press Load.

Timestamps are measured with performance.now() from the moment you press Load. Timer callbacks can run a little late if the page is busy.

Accessibility

Works with

Cursor
Reacts to where the pointer is, not just whether it's over the element.
Touch
Follows your finger while it's down, then settles a moment after you lift.
Keyboard
Focus lights it up the way the cursor does. Every action has a key.
Reduced motion
Nothing moves or springs. Colour still answers, without drifting.