Optimistic UI for Smart Locks
Optimistic UI for Smart Locks
animation
ux
interaction-patterns
NoteTry It Yourself
Hands-on exercises to reinforce interaction pattern concepts:
Optimistic UI for Smart Locks
Build a simple web interface that demonstrates optimistic UI with rollback:
- Create an HTML button labeled “Lock Door”
- On click, immediately show “Locked” state with loading spinner
- Simulate 2-second network delay with
setTimeout - 80% of the time, confirm lock success; 20% simulate failure
- On failure, revert to “Unlocked” and show toast message
What to observe: Notice how instant feedback feels more responsive than waiting 2 seconds. Test clicking the button multiple times rapidly—without optimistic UI, users queue multiple commands. With it, the button disables during pending state.