Your WhatsApp message starts with a little clock, then one tick, two ticks, and finally two blue ticks. You don't need to ask your friend whether it arrived. The screen already told you.
Those WhatsApp signs are feedback: the way a page tells people what is happening at every moment, such as loading, empty, failed or done. Each possible shape the page can be in is called a state. It's the same away from screens. Think of ordering at a food stall. You say "one fried rice", and the cook answers "sure, coming up". You see the wok start smoking, then the plate arrives. If there is no rice left, she says "sorry, no rice left, fried noodles instead?". If she says nothing after you order, you don't know whether you were heard, so you order a second time. The cook's "sure" and the smoking wok are feedback while you wait. A cook who says nothing is like a page with no feedback: the guest presses the book button twice.
Six states to design
Designers often draw only the page that worked and is full of data. Yet every part of a page has five basic states, plus one state for the connection. Here they all are, on the Mist Homestay booking page:
| State | When | On Mrs. Sri's page |
|---|---|---|
| Loading | waiting for data or an answer | room list: a skeleton; the Book button: "Booking..." |
| Empty | there really is no data | "No rooms free on 12 Dec." with a "See 13 Dec" button |
| Error | the request failed | "Booking not sent yet. Try again." The nights choice stays as it was |
| Success | the request worked | "Booking sent. Mrs. Sri will confirm on WhatsApp." |
| Partial | part of it worked | the room photo failed to load, but the price and the Book button still work |
| Offline | no connection | "You're offline. Your booking hasn't been sent yet." |
The first five states (empty, loading, error, success, partial) must be designed for every element that loads data. Offline is a special error that deserves its own message, because its cause and its way out are different: not "try again", but "connect to the internet first".
A good message says what happened and what to do next. "Error 500" (an error code from the server) helps nobody. "Booking not sent yet. Try again." helps, especially with a "Try again" button beside it.
How long the wait, which indicator
Jakob Nielsen, a usability researcher (Usability Engineering, 1993), gave three time limits that are still used today:
- 0.1 second feels instant,
- 1 second still keeps the flow of thought,
- 10 seconds is the limit for keeping people's attention while they wait.
From those three limits, Nielsen Norman Group (NN/g, Katie Sherwin, 2014) recommends these indicators (signs that the page is working):
| Wait | Indicator |
|---|---|
| under 1 second | no indicator needed |
| 2 to 10 seconds | a looped animation: a spinner or a skeleton |
| over 10 seconds | a progress bar showing percent done |
For 2 to 10 seconds, the choice depends on what is loading (NN/g, Samhita Tankala, 2023):
- Skeleton screen: grey boxes the size of the content to come (photo, room name, price). For loading a whole page or a whole list, a skeleton is better than a spinner. People already see the page's shape, and the content arrives in exactly the same place, with no jumping.
- Spinner: a spinning circle, for one small part or one action. For example, the Book button waiting for an answer from the server (the computer that receives the bookings).
The Book button while it waits
Mr. Hadi presses "Book the room, pay on arrival". The button only turns grey, with no text change, and 3 seconds later "Booking sent" appears. The page works, and the booking arrives. But something is wrong. Guess what, before you look at the fixed button code below.
<button class="book" id="book">Book the room, pay on arrival</button>
<p id="status" role="status"></p>
<p id="error" class="error" role="alert"></p>
<script>
const book = document.querySelector('#book');
book.addEventListener('click', async () => {
if (book.getAttribute('aria-disabled') === 'true') return; // don't book twice
book.setAttribute('aria-disabled', 'true');
book.textContent = 'Booking...';
try {
await sendBooking(); // fetch to Mrs. Sri's server
document.querySelector('#status').textContent = 'Booking sent. Mrs. Sri will confirm on WhatsApp.';
} catch {
document.querySelector('#error').textContent = 'Booking not sent yet. Try again.';
} finally {
book.setAttribute('aria-disabled', 'false');
book.textContent = 'Book the room, pay on arrival';
}
});
</script>
textContent = 'Booking...'changes the button's label. So the guest knows the tap was received and is being processed.aria-disabled="true"marks the button as unusable for now. Thereturnline at the top ignores a second tap, so the booking isn't sent twice.- Why not the
disabledattribute? We tested it in Chrome, Safari and Firefox. A focused button that getsdisabledloses focus, and focus falls to<body>(the whole page). Keyboard users lose their place. Witharia-disabled, focus stays on the button. tryruns the sending of the booking. If the sending fails, thecatchpart runs and writes the error message.finallyruns after success and failure alike, so the button always returns to normal.
So the answer to the guess: there's no loading feedback. A grey button with no label change could mean "processing", or it could mean "this button is off". Mr. Hadi can't tell whether his tap registered, and 3 seconds is in the range that needs an indicator.
aria-live: news that gets read out
Screen reader users don't see "Booking sent" appear. A live region (a part of the page that screen readers watch) makes text changes inside it read out automatically. WCAG 4.1.3 (Status Messages, level AA) requires that status messages such as "Booking sent" are read out too. There are two kinds of live region:
role="status"(the same asaria-live="polite"): read once the screen reader finishes speaking. For success news.role="alert"(the same asaria-live="assertive"): interrupts what is being read, and is read right away. For errors that need dealing with now.
Put the live region in the page, empty, from the moment the page loads. Then fill in its text when there's news. Screen readers watch regions that already exist. A region added together with its text is often not read out.
For a field with a wrong value, the error message also uses role="alert", plus two attributes on the field:
<label for="phone">Phone number</label>
<input id="phone" class="input-error" aria-invalid="true" aria-describedby="phone-error">
<span id="phone-error" class="error-msg" role="alert">A phone number must start with 08.</span>
<style>
.input-error { border: 1px solid #EF4444; } /* 3.76:1, enough for a line (3:1 minimum) */
.error-msg { color: #b91c1c; } /* 6.47:1, enough for text (4.5:1 minimum) */
</style>
aria-invalid="true"marks the value as wrong. A screen reader says the field is "invalid".aria-describedby="phone-error"links the field to its message'sid, so the message is read along with the field when the field gets focus.border: 1px solid #EF4444makes the field'sborder-color(the colour of its border)#EF4444, a visible red sign. The message text uses a darker red, because the contrast of#EF4444is only 3.76:1, below the 4.5:1 that text needs.
⚠️ When the page just goes quiet
- Designing only the success state. Mrs. Sri's very first user sees the empty state, because there is no data yet, and the connection in the mountains can drop.
- A button that just turns grey. It's unclear whether the button is working or off, and the
disabledattribute throws away keyboard focus. Change the label, and usearia-disabled. - A spinner for a whole page, or a skeleton for one button. A skeleton for loading a page or a list, a spinner for one action or one small part.
- An error that wipes the form. The nights choice and the guest's name must still be there after a failure.
role="alert"for every message. An alert interrupts whatever is being read. Success news only needsrole="status".
TL;DR: Design six states, not just success: loading, empty, error, success, partial (the five basic states), plus offline. Nielsen's limits: 0.1 second feels instant, 1 second keeps the flow of thought, 10 seconds is the limit of attention. Over 1 second, show an indicator. For 2 to 10 seconds, use a spinner (a spinning circle) or a skeleton (grey boxes the size of the content to come). Over 10 seconds, use a progress bar (a bar that shows the percent done). A skeleton screen is better for loading a page or a list, a spinner for one action. A waiting button changes its label ("Booking...") and uses aria-disabled (a mark that the button can't be used for now), not disabled, which throws keyboard focus away. So that screen readers read them out, success news goes in an element with role="status", and errors in one with role="alert" (WCAG 4.1.3). The element for those messages (the region) must already be there when the page loads. A field with a wrong value: aria-invalid="true", aria-describedby pointing at its message's id, border-color: #EF4444, and message text in #b91c1c.
⚡ Design five states, not just success
Meaning: A state is each possible shape a page can be in. Every element that loads data has five basic states: empty, loading, error, success (it worked), partial (part of it worked). Offline (no connection) gets a message of its own, because its way out is different: connect to the internet first. A good message says what happened and what to do next: "Booking not sent yet. Try again."
⚡ Skeleton or spinner
Meaning: Under 1 second, no indicator (a sign that the page is working) is needed. 2 to 10 seconds: a looped animation. Over 10 seconds: a progress bar (a bar that shows the percent done). For loading a whole page or list, a skeleton screen (grey boxes the size of the content to come) is better, because the content arrives in the same place with no jumping. A spinner (a spinning circle) is for one small action.
⚡ A waiting button has to say so
Write:
book.setAttribute('aria-disabled', 'true');
book.textContent = 'Booking...';
Guess first: Mr. Hadi presses the book button, it only turns grey, and 3 seconds later "Booking sent" appears. The booking arrives. What's wrong?
There's no feedback (no sign from the page) while it loads. A grey button with no new label could mean "processing", or it could mean "this button is off".
Meaning: book is the Book button. While it waits, change its label, and use aria-disabled (a mark that the button can't be used for now), not disabled, which throws keyboard focus away. So that screen readers read them out, success news goes into an element with role="status", and errors into one with role="alert". The element for those messages (a live region, a part of the page that screen readers watch) must already be there when the page loads.